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