Show More
@@ -1,136 +1,136 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:`ipython_config.py`. By setting the attributes in this file, you |
|
13 | is :file:`ipython_config.py`. By setting the attributes in this file, you | |
14 | can configure the application. A sample is provided in |
|
14 | can configure the application. A sample is provided in | |
15 | :mod:`IPython.config.default.ipython_config`. Simply copy this file to your |
|
15 | :mod:`IPython.config.default.ipython_config`. Simply copy this file to your | |
16 | IPython directory to start using it. |
|
16 | :ref:`IPython directory <ipython_dir>` to start using it. | |
17 |
|
17 | |||
18 | Most configuration attributes that this file accepts are associated with |
|
18 | Most configuration attributes that this file accepts are associated with | |
19 | classes that are subclasses of :class:`~IPython.core.component.Component`. |
|
19 | classes that are subclasses of :class:`~IPython.core.component.Component`. | |
20 |
|
20 | |||
21 | A few configuration attributes are not associated with a particular |
|
21 | A few configuration attributes are not associated with a particular | |
22 | :class:`~IPython.core.component.Component` subclass. These are application |
|
22 | :class:`~IPython.core.component.Component` subclass. These are application | |
23 | wide configuration attributes and are stored in the ``Global`` |
|
23 | wide configuration attributes and are stored in the ``Global`` | |
24 | sub-configuration section. We begin with a description of these |
|
24 | sub-configuration section. We begin with a description of these | |
25 | attributes. |
|
25 | attributes. | |
26 |
|
26 | |||
27 | Global configuration |
|
27 | Global configuration | |
28 | ==================== |
|
28 | ==================== | |
29 |
|
29 | |||
30 | Assuming that your configuration file has the following at the top:: |
|
30 | Assuming that your configuration file has the following at the top:: | |
31 |
|
31 | |||
32 | c = get_config() |
|
32 | c = get_config() | |
33 |
|
33 | |||
34 | the following attributes can be set in the ``Global`` section. |
|
34 | the following attributes can be set in the ``Global`` section. | |
35 |
|
35 | |||
36 | :attr:`c.Global.display_banner` |
|
36 | :attr:`c.Global.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.Global.classic` |
|
40 | :attr:`c.Global.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.Global.nosep` |
|
45 | :attr:`c.Global.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.Global.log_level` |
|
49 | :attr:`c.Global.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 |
|
53 | |||
54 | :attr:`c.Global.extensions` |
|
54 | :attr:`c.Global.extensions` | |
55 | A list of strings, each of which is an importable IPython extension. An |
|
55 | A list of strings, each of which is an importable IPython extension. An | |
56 | IPython extension is a regular Python module or package that has a |
|
56 | IPython extension is a regular Python module or package that has a | |
57 | :func:`load_ipython_extension(ip)` method. This method gets called when |
|
57 | :func:`load_ipython_extension(ip)` method. This method gets called when | |
58 | the extension is loaded with the currently running |
|
58 | the extension is loaded with the currently running | |
59 | :class:`~IPython.core.iplib.InteractiveShell` as its only argument. You |
|
59 | :class:`~IPython.core.iplib.InteractiveShell` as its only argument. You | |
60 | can put your extensions anywhere they can be imported but we add the |
|
60 | can put your extensions anywhere they can be imported but we add the | |
61 | :file:`extensions` subdirectory of the ipython directory to ``sys.path`` |
|
61 | :file:`extensions` subdirectory of the ipython directory to ``sys.path`` | |
62 | during extension loading, so you can put them there as well. Extensions |
|
62 | during extension loading, so you can put them there as well. Extensions | |
63 | are not executed in the user's interactive namespace and they must be pure |
|
63 | are not executed in the user's interactive namespace and they must be pure | |
64 | Python code. Extensions are the recommended way of customizing |
|
64 | Python code. Extensions are the recommended way of customizing | |
65 | :command:`ipython`. Extensions can provide an |
|
65 | :command:`ipython`. Extensions can provide an | |
66 | :func:`unload_ipython_extension` that will be called when the extension is |
|
66 | :func:`unload_ipython_extension` that will be called when the extension is | |
67 | unloaded. |
|
67 | unloaded. | |
68 |
|
68 | |||
69 | :attr:`c.Global.exec_lines` |
|
69 | :attr:`c.Global.exec_lines` | |
70 | A list of strings, each of which is Python code that is run in the user's |
|
70 | A list of strings, each of which is Python code that is run in the user's | |
71 | namespace after IPython start. These lines can contain full IPython syntax |
|
71 | namespace after IPython start. These lines can contain full IPython syntax | |
72 | with magics, etc. |
|
72 | with magics, etc. | |
73 |
|
73 | |||
74 | :attr:`c.Global.exec_files` |
|
74 | :attr:`c.Global.exec_files` | |
75 | A list of strings, each of which is the full pathname of a ``.py`` or |
|
75 | A list of strings, each of which is the full pathname of a ``.py`` or | |
76 | ``.ipy`` file that will be executed as IPython starts. These files are run |
|
76 | ``.ipy`` file that will be executed as IPython starts. These files are run | |
77 | in IPython in the user's namespace. Files with a ``.py`` extension need to |
|
77 | in IPython in the user's namespace. Files with a ``.py`` extension need to | |
78 | be pure Python. Files with a ``.ipy`` extension can have custom IPython |
|
78 | be pure Python. Files with a ``.ipy`` extension can have custom IPython | |
79 | syntax (magics, etc.). These files need to be in the cwd, the ipythondir |
|
79 | syntax (magics, etc.). These files need to be in the cwd, the ipythondir | |
80 | or be absolute paths. |
|
80 | or be absolute paths. | |
81 |
|
81 | |||
82 | Classes that can be configured |
|
82 | Classes that can be configured | |
83 | ============================== |
|
83 | ============================== | |
84 |
|
84 | |||
85 | The following classes can also be configured in the configuration file for |
|
85 | The following classes can also be configured in the configuration file for | |
86 | :command:`ipython`: |
|
86 | :command:`ipython`: | |
87 |
|
87 | |||
88 | * :class:`~IPython.core.iplib.InteractiveShell` |
|
88 | * :class:`~IPython.core.iplib.InteractiveShell` | |
89 |
|
89 | |||
90 | * :class:`~IPython.core.prefilter.PrefilterManager` |
|
90 | * :class:`~IPython.core.prefilter.PrefilterManager` | |
91 |
|
91 | |||
92 | * :class:`~IPython.core.alias.AliasManager` |
|
92 | * :class:`~IPython.core.alias.AliasManager` | |
93 |
|
93 | |||
94 | To see which attributes of these classes are configurable, please see the |
|
94 | To see which attributes of these classes are configurable, please see the | |
95 | source code for these classes, the class docstrings or the sample |
|
95 | source code for these classes, the class docstrings or the sample | |
96 | configuration file :mod:`IPython.config.default.ipython_config`. |
|
96 | configuration file :mod:`IPython.config.default.ipython_config`. | |
97 |
|
97 | |||
98 | Example |
|
98 | Example | |
99 | ======= |
|
99 | ======= | |
100 |
|
100 | |||
101 | For those who want to get a quick start, here is a sample |
|
101 | For those who want to get a quick start, here is a sample | |
102 | :file:`ipython_config.py` that sets some of the common configuration |
|
102 | :file:`ipython_config.py` that sets some of the common configuration | |
103 | attributes:: |
|
103 | attributes:: | |
104 |
|
104 | |||
105 | # sample ipython_config.py |
|
105 | # sample ipython_config.py | |
106 | c = get_config() |
|
106 | c = get_config() | |
107 |
|
107 | |||
108 | c.Global.display_banner = True |
|
108 | c.Global.display_banner = True | |
109 | c.Global.log_level = 20 |
|
109 | c.Global.log_level = 20 | |
110 | c.Global.extensions = [ |
|
110 | c.Global.extensions = [ | |
111 | 'myextension' |
|
111 | 'myextension' | |
112 | ] |
|
112 | ] | |
113 | c.Global.exec_lines = [ |
|
113 | c.Global.exec_lines = [ | |
114 | 'import numpy', |
|
114 | 'import numpy', | |
115 | 'import scipy' |
|
115 | 'import scipy' | |
116 | ] |
|
116 | ] | |
117 | c.Global.exec_files = [ |
|
117 | c.Global.exec_files = [ | |
118 | 'mycode.py', |
|
118 | 'mycode.py', | |
119 | 'fancy.ipy' |
|
119 | 'fancy.ipy' | |
120 | ] |
|
120 | ] | |
121 | c.InteractiveShell.autoindent = True |
|
121 | c.InteractiveShell.autoindent = True | |
122 | c.InteractiveShell.colors = 'LightBG' |
|
122 | c.InteractiveShell.colors = 'LightBG' | |
123 | c.InteractiveShell.confirm_exit = False |
|
123 | c.InteractiveShell.confirm_exit = False | |
124 | c.InteractiveShell.deep_reload = True |
|
124 | c.InteractiveShell.deep_reload = True | |
125 | c.InteractiveShell.editor = 'nano' |
|
125 | c.InteractiveShell.editor = 'nano' | |
126 | c.InteractiveShell.prompt_in1 = 'In [\#]: ' |
|
126 | c.InteractiveShell.prompt_in1 = 'In [\#]: ' | |
127 | c.InteractiveShell.prompt_in2 = ' .\D.: ' |
|
127 | c.InteractiveShell.prompt_in2 = ' .\D.: ' | |
128 | c.InteractiveShell.prompt_out = 'Out[\#]: ' |
|
128 | c.InteractiveShell.prompt_out = 'Out[\#]: ' | |
129 | c.InteractiveShell.prompts_pad_left = True |
|
129 | c.InteractiveShell.prompts_pad_left = True | |
130 | c.InteractiveShell.xmode = 'Context' |
|
130 | c.InteractiveShell.xmode = 'Context' | |
131 |
|
131 | |||
132 | c.PrefilterManager.multi_line_specials = True |
|
132 | c.PrefilterManager.multi_line_specials = True | |
133 |
|
133 | |||
134 | c.AliasManager.user_aliases = [ |
|
134 | c.AliasManager.user_aliases = [ | |
135 | ('la', 'ls -al') |
|
135 | ('la', 'ls -al') | |
136 | ] |
|
136 | ] |
General Comments 0
You need to be logged in to leave comments.
Login now