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