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