##// END OF EJS Templates
Fix doc reference
Thomas Kluyver -
Show More
@@ -1,231 +1,231 b''
1 .. _initial config:
1 .. _initial config:
2
2
3 =============================================================
3 =============================================================
4 Outdated configuration information that might still be useful
4 Outdated configuration information that might still be useful
5 =============================================================
5 =============================================================
6
6
7 .. warning::
7 .. warning::
8
8
9 All of the information in this file is outdated. Until the new
9 All of the information in this file is outdated. Until the new
10 configuration system is better documented, this material is being kept.
10 configuration system is better documented, this material is being kept.
11
11
12 This section will help you set various things in your environment for
12 This section will help you set various things in your environment for
13 your IPython sessions to be as efficient as possible. All of IPython's
13 your IPython sessions to be as efficient as possible. All of IPython's
14 configuration information, along with several example files, is stored
14 configuration information, along with several example files, is stored
15 in a directory named by default $HOME/.config/ipython if $HOME/.config
15 in a directory named by default $HOME/.config/ipython if $HOME/.config
16 exists (Linux), or $HOME/.ipython as a secondary default. You can change this by
16 exists (Linux), or $HOME/.ipython as a secondary default. You can change this by
17 defining the environment variable IPYTHONDIR, or at runtime with the
17 defining the environment variable IPYTHONDIR, or at runtime with the
18 command line option -ipythondir.
18 command line option -ipythondir.
19
19
20 If all goes well, the first time you run IPython it should automatically create
20 If all goes well, the first time you run IPython it should automatically create
21 a user copy of the config directory for you, based on its builtin defaults. You
21 a user copy of the config directory for you, based on its builtin defaults. You
22 can look at the files it creates to learn more about configuring the
22 can look at the files it creates to learn more about configuring the
23 system. The main file you will modify to configure IPython's behavior is called
23 system. The main file you will modify to configure IPython's behavior is called
24 ipythonrc (with a .ini extension under Windows), included for reference
24 ipythonrc (with a .ini extension under Windows), included for reference
25 :ref:`here <ipythonrc>`. This file is very commented and has many variables you
25 :ref:`here <ipythonrc>`. This file is very commented and has many variables you
26 can change to suit your taste, you can find more details :ref:`here
26 can change to suit your taste, you can find more details :ref:`here
27 <customization>`. Here we discuss the basic things you will want to make sure
27 <customization>`. Here we discuss the basic things you will want to make sure
28 things are working properly from the beginning.
28 things are working properly from the beginning.
29
29
30 Color
30 Color
31 =====
31 =====
32
32
33 The default IPython configuration has most bells and whistles turned on
33 The default IPython configuration has most bells and whistles turned on
34 (they're pretty safe). But there's one that may cause problems on some
34 (they're pretty safe). But there's one that may cause problems on some
35 systems: the use of color on screen for displaying information. This is
35 systems: the use of color on screen for displaying information. This is
36 very useful, since IPython can show prompts and exception tracebacks
36 very useful, since IPython can show prompts and exception tracebacks
37 with various colors, display syntax-highlighted source code, and in
37 with various colors, display syntax-highlighted source code, and in
38 general make it easier to visually parse information.
38 general make it easier to visually parse information.
39
39
40 The following terminals seem to handle the color sequences fine:
40 The following terminals seem to handle the color sequences fine:
41
41
42 * Linux main text console, KDE Konsole, Gnome Terminal, E-term,
42 * Linux main text console, KDE Konsole, Gnome Terminal, E-term,
43 rxvt, xterm.
43 rxvt, xterm.
44 * CDE terminal (tested under Solaris). This one boldfaces light colors.
44 * CDE terminal (tested under Solaris). This one boldfaces light colors.
45 * (X)Emacs buffers. See the emacs_ section for more details on
45 * (X)Emacs buffers. See the :ref:`emacs` section for more details on
46 using IPython with (X)Emacs.
46 using IPython with (X)Emacs.
47 * A Windows (XP/2k) command prompt with pyreadline_.
47 * A Windows (XP/2k) command prompt with pyreadline_.
48 * A Windows (XP/2k) CygWin shell. Although some users have reported
48 * A Windows (XP/2k) CygWin shell. Although some users have reported
49 problems; it is not clear whether there is an issue for everyone
49 problems; it is not clear whether there is an issue for everyone
50 or only under specific configurations. If you have full color
50 or only under specific configurations. If you have full color
51 support under cygwin, please post to the IPython mailing list so
51 support under cygwin, please post to the IPython mailing list so
52 this issue can be resolved for all users.
52 this issue can be resolved for all users.
53
53
54 .. _pyreadline: https://code.launchpad.net/pyreadline
54 .. _pyreadline: https://code.launchpad.net/pyreadline
55
55
56 These have shown problems:
56 These have shown problems:
57
57
58 * Windows command prompt in WinXP/2k logged into a Linux machine via
58 * Windows command prompt in WinXP/2k logged into a Linux machine via
59 telnet or ssh.
59 telnet or ssh.
60 * Windows native command prompt in WinXP/2k, without Gary Bishop's
60 * Windows native command prompt in WinXP/2k, without Gary Bishop's
61 extensions. Once Gary's readline library is installed, the normal
61 extensions. Once Gary's readline library is installed, the normal
62 WinXP/2k command prompt works perfectly.
62 WinXP/2k command prompt works perfectly.
63
63
64 Currently the following color schemes are available:
64 Currently the following color schemes are available:
65
65
66 * NoColor: uses no color escapes at all (all escapes are empty '' ''
66 * NoColor: uses no color escapes at all (all escapes are empty '' ''
67 strings). This 'scheme' is thus fully safe to use in any terminal.
67 strings). This 'scheme' is thus fully safe to use in any terminal.
68 * Linux: works well in Linux console type environments: dark
68 * Linux: works well in Linux console type environments: dark
69 background with light fonts. It uses bright colors for
69 background with light fonts. It uses bright colors for
70 information, so it is difficult to read if you have a light
70 information, so it is difficult to read if you have a light
71 colored background.
71 colored background.
72 * LightBG: the basic colors are similar to those in the Linux scheme
72 * LightBG: the basic colors are similar to those in the Linux scheme
73 but darker. It is easy to read in terminals with light backgrounds.
73 but darker. It is easy to read in terminals with light backgrounds.
74
74
75 IPython uses colors for two main groups of things: prompts and
75 IPython uses colors for two main groups of things: prompts and
76 tracebacks which are directly printed to the terminal, and the object
76 tracebacks which are directly printed to the terminal, and the object
77 introspection system which passes large sets of data through a pager.
77 introspection system which passes large sets of data through a pager.
78
78
79 Input/Output prompts and exception tracebacks
79 Input/Output prompts and exception tracebacks
80 =============================================
80 =============================================
81
81
82 You can test whether the colored prompts and tracebacks work on your
82 You can test whether the colored prompts and tracebacks work on your
83 system interactively by typing '%colors Linux' at the prompt (use
83 system interactively by typing '%colors Linux' at the prompt (use
84 '%colors LightBG' if your terminal has a light background). If the input
84 '%colors LightBG' if your terminal has a light background). If the input
85 prompt shows garbage like::
85 prompt shows garbage like::
86
86
87 [0;32mIn [[1;32m1[0;32m]: [0;00m
87 [0;32mIn [[1;32m1[0;32m]: [0;00m
88
88
89 instead of (in color) something like::
89 instead of (in color) something like::
90
90
91 In [1]:
91 In [1]:
92
92
93 this means that your terminal doesn't properly handle color escape
93 this means that your terminal doesn't properly handle color escape
94 sequences. You can go to a 'no color' mode by typing '%colors NoColor'.
94 sequences. You can go to a 'no color' mode by typing '%colors NoColor'.
95
95
96 You can try using a different terminal emulator program (Emacs users,
96 You can try using a different terminal emulator program (Emacs users,
97 see below). To permanently set your color preferences, edit the file
97 see below). To permanently set your color preferences, edit the file
98 $IPYTHONDIR/ipythonrc and set the colors option to the desired value.
98 $IPYTHONDIR/ipythonrc and set the colors option to the desired value.
99
99
100
100
101 Object details (types, docstrings, source code, etc.)
101 Object details (types, docstrings, source code, etc.)
102 =====================================================
102 =====================================================
103
103
104 IPython has a set of special functions for studying the objects you are working
104 IPython has a set of special functions for studying the objects you are working
105 with, discussed in detail :ref:`here <dynamic_object_info>`. But this system
105 with, discussed in detail :ref:`here <dynamic_object_info>`. But this system
106 relies on passing information which is longer than your screen through a data
106 relies on passing information which is longer than your screen through a data
107 pager, such as the common Unix less and more programs. In order to be able to
107 pager, such as the common Unix less and more programs. In order to be able to
108 see this information in color, your pager needs to be properly configured. I
108 see this information in color, your pager needs to be properly configured. I
109 strongly recommend using less instead of more, as it seems that more simply can
109 strongly recommend using less instead of more, as it seems that more simply can
110 not understand colored text correctly.
110 not understand colored text correctly.
111
111
112 In order to configure less as your default pager, do the following:
112 In order to configure less as your default pager, do the following:
113
113
114 1. Set the environment PAGER variable to less.
114 1. Set the environment PAGER variable to less.
115 2. Set the environment LESS variable to -r (plus any other options
115 2. Set the environment LESS variable to -r (plus any other options
116 you always want to pass to less by default). This tells less to
116 you always want to pass to less by default). This tells less to
117 properly interpret control sequences, which is how color
117 properly interpret control sequences, which is how color
118 information is given to your terminal.
118 information is given to your terminal.
119
119
120 For the bash shell, add to your ~/.bashrc file the lines::
120 For the bash shell, add to your ~/.bashrc file the lines::
121
121
122 export PAGER=less
122 export PAGER=less
123 export LESS=-r
123 export LESS=-r
124
124
125 For the csh or tcsh shells, add to your ~/.cshrc file the lines::
125 For the csh or tcsh shells, add to your ~/.cshrc file the lines::
126
126
127 setenv PAGER less
127 setenv PAGER less
128 setenv LESS -r
128 setenv LESS -r
129
129
130 There is similar syntax for other Unix shells, look at your system
130 There is similar syntax for other Unix shells, look at your system
131 documentation for details.
131 documentation for details.
132
132
133 If you are on a system which lacks proper data pagers (such as Windows),
133 If you are on a system which lacks proper data pagers (such as Windows),
134 IPython will use a very limited builtin pager.
134 IPython will use a very limited builtin pager.
135
135
136 .. _Prompts:
136 .. _Prompts:
137
137
138 Fine-tuning your prompt
138 Fine-tuning your prompt
139 =======================
139 =======================
140
140
141 IPython's prompts can be customized using a syntax similar to that of
141 IPython's prompts can be customized using a syntax similar to that of
142 the bash shell. Many of bash's escapes are supported, as well as a few
142 the bash shell. Many of bash's escapes are supported, as well as a few
143 additional ones. We list them below::
143 additional ones. We list them below::
144
144
145 \#
145 \#
146 the prompt/history count number. This escape is automatically
146 the prompt/history count number. This escape is automatically
147 wrapped in the coloring codes for the currently active color scheme.
147 wrapped in the coloring codes for the currently active color scheme.
148 \N
148 \N
149 the 'naked' prompt/history count number: this is just the number
149 the 'naked' prompt/history count number: this is just the number
150 itself, without any coloring applied to it. This lets you produce
150 itself, without any coloring applied to it. This lets you produce
151 numbered prompts with your own colors.
151 numbered prompts with your own colors.
152 \D
152 \D
153 the prompt/history count, with the actual digits replaced by dots.
153 the prompt/history count, with the actual digits replaced by dots.
154 Used mainly in continuation prompts (prompt_in2)
154 Used mainly in continuation prompts (prompt_in2)
155 \w
155 \w
156 the current working directory
156 the current working directory
157 \W
157 \W
158 the basename of current working directory
158 the basename of current working directory
159 \Xn
159 \Xn
160 where $n=0\ldots5.$ The current working directory, with $HOME
160 where $n=0\ldots5.$ The current working directory, with $HOME
161 replaced by ~, and filtered out to contain only $n$ path elements
161 replaced by ~, and filtered out to contain only $n$ path elements
162 \Yn
162 \Yn
163 Similar to \Xn, but with the $n+1$ element included if it is ~ (this
163 Similar to \Xn, but with the $n+1$ element included if it is ~ (this
164 is similar to the behavior of the %cn escapes in tcsh)
164 is similar to the behavior of the %cn escapes in tcsh)
165 \u
165 \u
166 the username of the current user
166 the username of the current user
167 \$
167 \$
168 if the effective UID is 0, a #, otherwise a $
168 if the effective UID is 0, a #, otherwise a $
169 \h
169 \h
170 the hostname up to the first '.'
170 the hostname up to the first '.'
171 \H
171 \H
172 the hostname
172 the hostname
173 \n
173 \n
174 a newline
174 a newline
175 \r
175 \r
176 a carriage return
176 a carriage return
177 \v
177 \v
178 IPython version string
178 IPython version string
179
179
180 In addition to these, ANSI color escapes can be insterted into the
180 In addition to these, ANSI color escapes can be insterted into the
181 prompts, as \C_ColorName. The list of valid color names is: Black, Blue,
181 prompts, as \C_ColorName. The list of valid color names is: Black, Blue,
182 Brown, Cyan, DarkGray, Green, LightBlue, LightCyan, LightGray,
182 Brown, Cyan, DarkGray, Green, LightBlue, LightCyan, LightGray,
183 LightGreen, LightPurple, LightRed, NoColor, Normal, Purple, Red, White,
183 LightGreen, LightPurple, LightRed, NoColor, Normal, Purple, Red, White,
184 Yellow.
184 Yellow.
185
185
186 Finally, IPython supports the evaluation of arbitrary expressions in
186 Finally, IPython supports the evaluation of arbitrary expressions in
187 your prompt string. The prompt strings are evaluated through the syntax
187 your prompt string. The prompt strings are evaluated through the syntax
188 of PEP 215, but basically you can use $x.y to expand the value of x.y,
188 of PEP 215, but basically you can use $x.y to expand the value of x.y,
189 and for more complicated expressions you can use braces: ${foo()+x} will
189 and for more complicated expressions you can use braces: ${foo()+x} will
190 call function foo and add to it the value of x, before putting the
190 call function foo and add to it the value of x, before putting the
191 result into your prompt. For example, using
191 result into your prompt. For example, using
192 prompt_in1 '${commands.getoutput("uptime")}\nIn [\#]: '
192 prompt_in1 '${commands.getoutput("uptime")}\nIn [\#]: '
193 will print the result of the uptime command on each prompt (assuming the
193 will print the result of the uptime command on each prompt (assuming the
194 commands module has been imported in your ipythonrc file).
194 commands module has been imported in your ipythonrc file).
195
195
196
196
197 Prompt examples
197 Prompt examples
198
198
199 The following options in an ipythonrc file will give you IPython's
199 The following options in an ipythonrc file will give you IPython's
200 default prompts::
200 default prompts::
201
201
202 prompt_in1 'In [\#]:'
202 prompt_in1 'In [\#]:'
203 prompt_in2 ' .\D.:'
203 prompt_in2 ' .\D.:'
204 prompt_out 'Out[\#]:'
204 prompt_out 'Out[\#]:'
205
205
206 which look like this::
206 which look like this::
207
207
208 In [1]: 1+2
208 In [1]: 1+2
209 Out[1]: 3
209 Out[1]: 3
210
210
211 In [2]: for i in (1,2,3):
211 In [2]: for i in (1,2,3):
212 ...: print i,
212 ...: print i,
213 ...:
213 ...:
214 1 2 3
214 1 2 3
215
215
216 These will give you a very colorful prompt with path information::
216 These will give you a very colorful prompt with path information::
217
217
218 #prompt_in1 '\C_Red\u\C_Blue[\C_Cyan\Y1\C_Blue]\C_LightGreen\#>'
218 #prompt_in1 '\C_Red\u\C_Blue[\C_Cyan\Y1\C_Blue]\C_LightGreen\#>'
219 prompt_in2 ' ..\D>'
219 prompt_in2 ' ..\D>'
220 prompt_out '<\#>'
220 prompt_out '<\#>'
221
221
222 which look like this::
222 which look like this::
223
223
224 fperez[~/ipython]1> 1+2
224 fperez[~/ipython]1> 1+2
225 <1> 3
225 <1> 3
226 fperez[~/ipython]2> for i in (1,2,3):
226 fperez[~/ipython]2> for i in (1,2,3):
227 ...> print i,
227 ...> print i,
228 ...>
228 ...>
229 1 2 3
229 1 2 3
230
230
231
231
General Comments 0
You need to be logged in to leave comments. Login now