##// END OF EJS Templates
Mention that some options cannot be set through %config
Thomas Kluyver -
Show More
@@ -1,155 +1,156 b''
1 =====================================
1 =====================================
2 Introduction to IPython configuration
2 Introduction to IPython configuration
3 =====================================
3 =====================================
4
4
5 .. _setting_config:
5 .. _setting_config:
6
6
7 Setting configurable options
7 Setting configurable options
8 ============================
8 ============================
9
9
10 Many of IPython's classes have configurable attributes (see
10 Many of IPython's classes have configurable attributes (see
11 :doc:`options/index` for the list). These can be
11 :doc:`options/index` for the list). These can be
12 configured in several ways.
12 configured in several ways.
13
13
14 Python config files
14 Python config files
15 -------------------
15 -------------------
16
16
17 To create the blank config files, run::
17 To create the blank config files, run::
18
18
19 ipython profile create [profilename]
19 ipython profile create [profilename]
20
20
21 If you leave out the profile name, the files will be created for the
21 If you leave out the profile name, the files will be created for the
22 ``default`` profile (see :ref:`profiles`). These will typically be
22 ``default`` profile (see :ref:`profiles`). These will typically be
23 located in :file:`~/.ipython/profile_default/`, and will be named
23 located in :file:`~/.ipython/profile_default/`, and will be named
24 :file:`ipython_config.py`, :file:`ipython_notebook_config.py`, etc.
24 :file:`ipython_config.py`, :file:`ipython_notebook_config.py`, etc.
25 The settings in :file:`ipython_config.py` apply to all IPython commands.
25 The settings in :file:`ipython_config.py` apply to all IPython commands.
26
26
27 The files typically start by getting the root config object::
27 The files typically start by getting the root config object::
28
28
29 c = get_config()
29 c = get_config()
30
30
31 You can then configure class attributes like this::
31 You can then configure class attributes like this::
32
32
33 c.InteractiveShell.automagic = False
33 c.InteractiveShell.automagic = False
34
34
35 Be careful with spelling--incorrect names will simply be ignored, with
35 Be careful with spelling--incorrect names will simply be ignored, with
36 no error.
36 no error.
37
37
38 To add to a collection which may have already been defined elsewhere,
38 To add to a collection which may have already been defined elsewhere,
39 you can use methods like those found on lists, dicts and sets: append,
39 you can use methods like those found on lists, dicts and sets: append,
40 extend, :meth:`~IPython.config.loader.LazyConfigValue.prepend` (like
40 extend, :meth:`~IPython.config.loader.LazyConfigValue.prepend` (like
41 extend, but at the front), add and update (which works both for dicts
41 extend, but at the front), add and update (which works both for dicts
42 and sets)::
42 and sets)::
43
43
44 c.InteractiveShellApp.extensions.append('rmagic')
44 c.InteractiveShellApp.extensions.append('rmagic')
45
45
46 .. versionadded:: 2.0
46 .. versionadded:: 2.0
47 list, dict and set methods for config values
47 list, dict and set methods for config values
48
48
49 Example config file
49 Example config file
50 ```````````````````
50 ```````````````````
51
51
52 ::
52 ::
53
53
54 # sample ipython_config.py
54 # sample ipython_config.py
55 c = get_config()
55 c = get_config()
56
56
57 c.TerminalIPythonApp.display_banner = True
57 c.TerminalIPythonApp.display_banner = True
58 c.InteractiveShellApp.log_level = 20
58 c.InteractiveShellApp.log_level = 20
59 c.InteractiveShellApp.extensions = [
59 c.InteractiveShellApp.extensions = [
60 'myextension'
60 'myextension'
61 ]
61 ]
62 c.InteractiveShellApp.exec_lines = [
62 c.InteractiveShellApp.exec_lines = [
63 'import numpy',
63 'import numpy',
64 'import scipy'
64 'import scipy'
65 ]
65 ]
66 c.InteractiveShellApp.exec_files = [
66 c.InteractiveShellApp.exec_files = [
67 'mycode.py',
67 'mycode.py',
68 'fancy.ipy'
68 'fancy.ipy'
69 ]
69 ]
70 c.InteractiveShell.autoindent = True
70 c.InteractiveShell.autoindent = True
71 c.InteractiveShell.colors = 'LightBG'
71 c.InteractiveShell.colors = 'LightBG'
72 c.InteractiveShell.confirm_exit = False
72 c.InteractiveShell.confirm_exit = False
73 c.InteractiveShell.deep_reload = True
73 c.InteractiveShell.deep_reload = True
74 c.InteractiveShell.editor = 'nano'
74 c.InteractiveShell.editor = 'nano'
75 c.InteractiveShell.xmode = 'Context'
75 c.InteractiveShell.xmode = 'Context'
76
76
77 c.PromptManager.in_template = 'In [\#]: '
77 c.PromptManager.in_template = 'In [\#]: '
78 c.PromptManager.in2_template = ' .\D.: '
78 c.PromptManager.in2_template = ' .\D.: '
79 c.PromptManager.out_template = 'Out[\#]: '
79 c.PromptManager.out_template = 'Out[\#]: '
80 c.PromptManager.justify = True
80 c.PromptManager.justify = True
81
81
82 c.PrefilterManager.multi_line_specials = True
82 c.PrefilterManager.multi_line_specials = True
83
83
84 c.AliasManager.user_aliases = [
84 c.AliasManager.user_aliases = [
85 ('la', 'ls -al')
85 ('la', 'ls -al')
86 ]
86 ]
87
87
88
88
89 Command line arguments
89 Command line arguments
90 ----------------------
90 ----------------------
91
91
92 Every configurable value can be set from the command line, using this
92 Every configurable value can be set from the command line, using this
93 syntax::
93 syntax::
94
94
95 ipython --ClassName.attribute=value
95 ipython --ClassName.attribute=value
96
96
97 Many frequently used options have short aliases and flags, such as
97 Many frequently used options have short aliases and flags, such as
98 ``--matplotlib`` (to integrate with a matplotlib GUI event loop) or
98 ``--matplotlib`` (to integrate with a matplotlib GUI event loop) or
99 ``--pdb`` (automatic post-mortem debugging of exceptions).
99 ``--pdb`` (automatic post-mortem debugging of exceptions).
100
100
101 To see all of these abbreviated options, run::
101 To see all of these abbreviated options, run::
102
102
103 ipython --help
103 ipython --help
104 ipython notebook --help
104 ipython notebook --help
105 # etc.
105 # etc.
106
106
107 Options specified at the command line, in either format, override
107 Options specified at the command line, in either format, override
108 options set in a configuration file.
108 options set in a configuration file.
109
109
110 The config magic
110 The config magic
111 ----------------
111 ----------------
112
112
113 You can also modify config from inside IPython, using a magic command::
113 You can also modify config from inside IPython, using a magic command::
114
114
115 %config IPCompleter.greedy = True
115 %config IPCompleter.greedy = True
116
116
117 At present, this only affects the current session - changes you make to
117 At present, this only affects the current session - changes you make to
118 config are not saved anywhere.
118 config are not saved anywhere. Also, some options are only read when
119 IPython starts, so they can't be changed like this.
119
120
120 .. _profiles:
121 .. _profiles:
121
122
122 Profiles
123 Profiles
123 ========
124 ========
124
125
125 IPython can use multiple profiles, with separate configuration and
126 IPython can use multiple profiles, with separate configuration and
126 history. By default, if you don't specify a profile, IPython always runs
127 history. By default, if you don't specify a profile, IPython always runs
127 in the ``default`` profile. To use a new profile::
128 in the ``default`` profile. To use a new profile::
128
129
129 ipython profile create foo # create the profile foo
130 ipython profile create foo # create the profile foo
130 ipython --profile=foo # start IPython using the new profile
131 ipython --profile=foo # start IPython using the new profile
131
132
132 Profiles are typically stored in :ref:`ipythondir`, but you can also keep
133 Profiles are typically stored in :ref:`ipythondir`, but you can also keep
133 a profile in the current working directory, for example to distribute it
134 a profile in the current working directory, for example to distribute it
134 with a project. To find a profile directory on the filesystem::
135 with a project. To find a profile directory on the filesystem::
135
136
136 ipython locate profile foo
137 ipython locate profile foo
137
138
138 .. _ipythondir:
139 .. _ipythondir:
139
140
140 The IPython directory
141 The IPython directory
141 =====================
142 =====================
142
143
143 IPython stores its files---config, command history and extensions---in
144 IPython stores its files---config, command history and extensions---in
144 the directory :file:`~/.ipython/` by default.
145 the directory :file:`~/.ipython/` by default.
145
146
146 .. envvar:: IPYTHONDIR
147 .. envvar:: IPYTHONDIR
147
148
148 If set, this environment variable should be the path to a directory,
149 If set, this environment variable should be the path to a directory,
149 which IPython will use for user data. IPython will create it if it
150 which IPython will use for user data. IPython will create it if it
150 does not exist.
151 does not exist.
151
152
152 .. option:: --ipython-dir=<path>
153 .. option:: --ipython-dir=<path>
153
154
154 This command line option can also be used to override the default
155 This command line option can also be used to override the default
155 IPython directory.
156 IPython directory.
General Comments 0
You need to be logged in to leave comments. Login now