Show More
@@ -1,137 +1,138 b'' | |||||
1 | .. _configuring_ipython: |
|
1 | .. _configuring_ipython: | |
2 |
|
2 | |||
3 | =========================================================== |
|
3 | =========================================================== | |
4 | Configuring the :command:`ipython` command line application |
|
4 | Configuring the :command:`ipython` command line application | |
5 | =========================================================== |
|
5 | =========================================================== | |
6 |
|
6 | |||
7 | This section contains information about how to configure the |
|
7 | This section contains information about how to configure the | |
8 | :command:`ipython` command line application. See the :ref:`configuration |
|
8 | :command:`ipython` command line application. See the :ref:`configuration | |
9 | overview <config_overview>` for a more general description of the |
|
9 | overview <config_overview>` for a more general description of the | |
10 | configuration system and configuration file format. |
|
10 | configuration system and configuration file format. | |
11 |
|
11 | |||
12 | The default configuration file for the :command:`ipython` command line application |
|
12 | The default configuration file for the :command:`ipython` command line application | |
13 | is :file:`profile_default/ipython_config.py` in your :ref:`IPython directory |
|
13 | is :file:`profile_default/ipython_config.py` in your :ref:`IPython directory | |
14 | <ipython_dir>`. By setting the attributes in this file, you can configure the |
|
14 | <ipython_dir>`. By setting the attributes in this file, you can configure the | |
15 | application. To create the default config file, run this command:: |
|
15 | application. To create the default config file, run this command:: | |
16 |
|
16 | |||
17 | $ ipython profile create |
|
17 | $ ipython profile create | |
18 |
|
18 | |||
19 | Most configuration attributes that this file accepts are associated with classes |
|
19 | Most configuration attributes that this file accepts are associated with classes | |
20 | that are subclasses of :class:`~IPython.config.configurable.Configurable`. |
|
20 | that are subclasses of :class:`~IPython.config.configurable.Configurable`. | |
21 |
|
21 | |||
22 | Applications themselves are Configurable as well, so we will start with some |
|
22 | Applications themselves are Configurable as well, so we will start with some | |
23 | application-level config. |
|
23 | application-level config. | |
24 |
|
24 | |||
25 | Application-level configuration |
|
25 | Application-level configuration | |
26 | =============================== |
|
26 | =============================== | |
27 |
|
27 | |||
28 | Assuming that your configuration file has the following at the top:: |
|
28 | Assuming that your configuration file has the following at the top:: | |
29 |
|
29 | |||
30 | c = get_config() |
|
30 | c = get_config() | |
31 |
|
31 | |||
32 | the following attributes are set application-wide: |
|
32 | the following attributes are set application-wide: | |
33 |
|
33 | |||
34 | terminal IPython-only flags: |
|
34 | terminal IPython-only flags: | |
35 |
|
35 | |||
36 | :attr:`c.TerminalIPythonApp.display_banner` |
|
36 | :attr:`c.TerminalIPythonApp.display_banner` | |
37 | A boolean that determined if the banner is printer when :command:`ipython` |
|
37 | A boolean that determined if the banner is printer when :command:`ipython` | |
38 | is started. |
|
38 | is started. | |
39 |
|
39 | |||
40 | :attr:`c.TerminalIPythonApp.classic` |
|
40 | :attr:`c.TerminalIPythonApp.classic` | |
41 | A boolean that determines if IPython starts in "classic" mode. In this |
|
41 | A boolean that determines if IPython starts in "classic" mode. In this | |
42 | mode, the prompts and everything mimic that of the normal :command:`python` |
|
42 | mode, the prompts and everything mimic that of the normal :command:`python` | |
43 | shell |
|
43 | shell | |
44 |
|
44 | |||
45 | :attr:`c.TerminalIPythonApp.nosep` |
|
45 | :attr:`c.TerminalIPythonApp.nosep` | |
46 | A boolean that determines if there should be no blank lines between |
|
46 | A boolean that determines if there should be no blank lines between | |
47 | prompts. |
|
47 | prompts. | |
48 |
|
48 | |||
49 | :attr:`c.Application.log_level` |
|
49 | :attr:`c.Application.log_level` | |
50 | An integer that sets the detail of the logging level during the startup |
|
50 | An integer that sets the detail of the logging level during the startup | |
51 | of :command:`ipython`. The default is 30 and the possible values are |
|
51 | of :command:`ipython`. The default is 30 and the possible values are | |
52 | (0, 10, 20, 30, 40, 50). Higher is quieter and lower is more verbose. |
|
52 | (0, 10, 20, 30, 40, 50). Higher is quieter and lower is more verbose. | |
53 | This can also be set by the name of the logging level, e.g. INFO=20, |
|
53 | This can also be set by the name of the logging level, e.g. INFO=20, | |
54 | WARN=30. |
|
54 | WARN=30. | |
55 |
|
55 | |||
56 | Some options, such as extensions and startup code, can be set for any |
|
56 | Some options, such as extensions and startup code, can be set for any | |
57 | application that starts an |
|
57 | application that starts an | |
58 | :class:`~IPython.core.interactiveshell.InteractiveShell`. These apps are |
|
58 | :class:`~IPython.core.interactiveshell.InteractiveShell`. These apps are | |
59 | subclasses of :class:`~IPython.core.shellapp.InteractiveShellApp`. Since |
|
59 | subclasses of :class:`~IPython.core.shellapp.InteractiveShellApp`. Since | |
60 | subclasses inherit configuration, setting a trait of |
|
60 | subclasses inherit configuration, setting a trait of | |
61 | :attr:`c.InteractiveShellApp` will affect all IPython applications, but if you |
|
61 | :attr:`c.InteractiveShellApp` will affect all IPython applications, but if you | |
62 | want terminal IPython and the QtConsole to have different values, you can set |
|
62 | want terminal IPython and the QtConsole to have different values, you can set | |
63 | them via :attr:`c.TerminalIPythonApp` and :attr:`c.IPKernelApp` respectively. |
|
63 | them via :attr:`c.TerminalIPythonApp` and :attr:`c.IPKernelApp` respectively. | |
64 |
|
64 | |||
65 |
|
65 | |||
66 | :attr:`c.InteractiveShellApp.extensions` |
|
66 | :attr:`c.InteractiveShellApp.extensions` | |
67 | A list of strings, each of which is an importable IPython extension. See |
|
67 | A list of strings, each of which is an importable IPython extension. See | |
68 | :ref:`extensions_overview` for more details about extensions. |
|
68 | :ref:`extensions_overview` for more details about extensions. | |
69 |
|
69 | |||
70 | :attr:`c.InteractiveShellApp.exec_lines` |
|
70 | :attr:`c.InteractiveShellApp.exec_lines` | |
71 | A list of strings, each of which is Python code that is run in the user's |
|
71 | A list of strings, each of which is Python code that is run in the user's | |
72 | namespace after IPython start. These lines can contain full IPython syntax |
|
72 | namespace after IPython start. These lines can contain full IPython syntax | |
73 | with magics, etc. |
|
73 | with magics, etc. | |
74 |
|
74 | |||
75 | :attr:`c.InteractiveShellApp.exec_files` |
|
75 | :attr:`c.InteractiveShellApp.exec_files` | |
76 | A list of strings, each of which is the full pathname of a ``.py`` or |
|
76 | A list of strings, each of which is the full pathname of a ``.py`` or | |
77 | ``.ipy`` file that will be executed as IPython starts. These files are run |
|
77 | ``.ipy`` file that will be executed as IPython starts. These files are run | |
78 | in IPython in the user's namespace. Files with a ``.py`` extension need to |
|
78 | in IPython in the user's namespace. Files with a ``.py`` extension need to | |
79 | be pure Python. Files with a ``.ipy`` extension can have custom IPython |
|
79 | be pure Python. Files with a ``.ipy`` extension can have custom IPython | |
80 | syntax (magics, etc.). These files need to be in the cwd, the ipythondir |
|
80 | syntax (magics, etc.). These files need to be in the cwd, the ipythondir | |
81 | or be absolute paths. |
|
81 | or be absolute paths. | |
82 |
|
82 | |||
83 | Classes that can be configured |
|
83 | Classes that can be configured | |
84 | ============================== |
|
84 | ============================== | |
85 |
|
85 | |||
86 | The following classes can also be configured in the configuration file for |
|
86 | The following classes can also be configured in the configuration file for | |
87 | :command:`ipython`: |
|
87 | :command:`ipython`: | |
88 |
|
88 | |||
89 | * :class:`~IPython.core.interactiveshell.InteractiveShell` |
|
89 | * :class:`~IPython.core.interactiveshell.InteractiveShell` | |
90 |
|
90 | |||
91 | * :class:`~IPython.core.prefilter.PrefilterManager` |
|
91 | * :class:`~IPython.core.prefilter.PrefilterManager` | |
92 |
|
92 | |||
93 | * :class:`~IPython.core.alias.AliasManager` |
|
93 | * :class:`~IPython.core.alias.AliasManager` | |
94 |
|
94 | |||
95 | To see which attributes of these classes are configurable, please see the |
|
95 | To see which attributes of these classes are configurable, please see the | |
96 | source code for these classes, the class docstrings or the sample |
|
96 | source code for these classes, the class docstrings or the sample | |
97 | configuration file :mod:`IPython.config.default.ipython_config`. |
|
97 | configuration file :mod:`IPython.config.default.ipython_config`. | |
98 |
|
98 | |||
99 | Example |
|
99 | Example | |
100 | ======= |
|
100 | ======= | |
101 |
|
101 | |||
102 | For those who want to get a quick start, here is a sample |
|
102 | For those who want to get a quick start, here is a sample | |
103 | :file:`ipython_config.py` that sets some of the common configuration |
|
103 | :file:`ipython_config.py` that sets some of the common configuration | |
104 | attributes:: |
|
104 | attributes:: | |
105 |
|
105 | |||
106 | # sample ipython_config.py |
|
106 | # sample ipython_config.py | |
107 | c = get_config() |
|
107 | c = get_config() | |
108 |
|
108 | |||
109 | c.TerminalIPythonApp.display_banner = True |
|
109 | c.TerminalIPythonApp.display_banner = True | |
110 | c.InteractiveShellApp.log_level = 20 |
|
110 | c.InteractiveShellApp.log_level = 20 | |
111 | c.InteractiveShellApp.extensions = [ |
|
111 | c.InteractiveShellApp.extensions = [ | |
112 | 'myextension' |
|
112 | 'myextension' | |
113 | ] |
|
113 | ] | |
114 | c.InteractiveShellApp.exec_lines = [ |
|
114 | c.InteractiveShellApp.exec_lines = [ | |
115 | 'import numpy', |
|
115 | 'import numpy', | |
116 | 'import scipy' |
|
116 | 'import scipy' | |
117 | ] |
|
117 | ] | |
118 | c.InteractiveShellApp.exec_files = [ |
|
118 | c.InteractiveShellApp.exec_files = [ | |
119 | 'mycode.py', |
|
119 | 'mycode.py', | |
120 | 'fancy.ipy' |
|
120 | 'fancy.ipy' | |
121 | ] |
|
121 | ] | |
122 | c.InteractiveShell.autoindent = True |
|
122 | c.InteractiveShell.autoindent = True | |
123 | c.InteractiveShell.colors = 'LightBG' |
|
123 | c.InteractiveShell.colors = 'LightBG' | |
124 | c.InteractiveShell.confirm_exit = False |
|
124 | c.InteractiveShell.confirm_exit = False | |
125 | c.InteractiveShell.deep_reload = True |
|
125 | c.InteractiveShell.deep_reload = True | |
126 | c.InteractiveShell.editor = 'nano' |
|
126 | c.InteractiveShell.editor = 'nano' | |
127 | c.InteractiveShell.prompt_in1 = 'In [\#]: ' |
|
|||
128 | c.InteractiveShell.prompt_in2 = ' .\D.: ' |
|
|||
129 | c.InteractiveShell.prompt_out = 'Out[\#]: ' |
|
|||
130 | c.InteractiveShell.prompts_pad_left = True |
|
|||
131 | c.InteractiveShell.xmode = 'Context' |
|
127 | c.InteractiveShell.xmode = 'Context' | |
|
128 | ||||
|
129 | c.PromptManager.in_template = 'In [\#]: ' | |||
|
130 | c.PromptManager.in2_template = ' .\D.: ' | |||
|
131 | c.PromptManager.out_template = 'Out[\#]: ' | |||
|
132 | c.PromptManager.justify = True | |||
132 |
|
133 | |||
133 | c.PrefilterManager.multi_line_specials = True |
|
134 | c.PrefilterManager.multi_line_specials = True | |
134 |
|
135 | |||
135 | c.AliasManager.user_aliases = [ |
|
136 | c.AliasManager.user_aliases = [ | |
136 | ('la', 'ls -al') |
|
137 | ('la', 'ls -al') | |
137 | ] |
|
138 | ] |
General Comments 0
You need to be logged in to leave comments.
Login now