Show More
@@ -1,168 +1,168 | |||
|
1 | 1 | ======================= |
|
2 | 2 | Specific config details |
|
3 | 3 | ======================= |
|
4 | 4 | |
|
5 | 5 | .. _termcolour: |
|
6 | 6 | |
|
7 | 7 | Terminal Colors |
|
8 | 8 | =============== |
|
9 | 9 | |
|
10 | 10 | The default IPython configuration has most bells and whistles turned on |
|
11 | 11 | (they're pretty safe). But there's one that may cause problems on some |
|
12 | 12 | systems: the use of color on screen for displaying information. This is |
|
13 | 13 | very useful, since IPython can show prompts and exception tracebacks |
|
14 | 14 | with various colors, display syntax-highlighted source code, and in |
|
15 | 15 | general make it easier to visually parse information. |
|
16 | 16 | |
|
17 | 17 | The following terminals seem to handle the color sequences fine: |
|
18 | 18 | |
|
19 | 19 | * Linux main text console, KDE Konsole, Gnome Terminal, E-term, |
|
20 | 20 | rxvt, xterm. |
|
21 | 21 | * CDE terminal (tested under Solaris). This one boldfaces light colors. |
|
22 | 22 | * (X)Emacs buffers. See the :ref:`emacs` section for more details on |
|
23 | 23 | using IPython with (X)Emacs. |
|
24 | 24 | * A Windows (XP/2k) CygWin shell. Although some users have reported |
|
25 | 25 | problems; it is not clear whether there is an issue for everyone |
|
26 | 26 | or only under specific configurations. If you have full color |
|
27 | 27 | support under cygwin, please post to the IPython mailing list so |
|
28 | 28 | this issue can be resolved for all users. |
|
29 | 29 | |
|
30 | 30 | These have shown problems: |
|
31 | 31 | |
|
32 | 32 | * Windows command prompt in WinXP/2k logged into a Linux machine via |
|
33 | 33 | telnet or ssh. |
|
34 | 34 | * Windows native command prompt in WinXP/2k, without Gary Bishop's |
|
35 | 35 | extensions. Once Gary's readline library is installed, the normal |
|
36 | 36 | WinXP/2k command prompt works perfectly. |
|
37 | 37 | |
|
38 | 38 | IPython uses colors for various groups of things that may be |
|
39 | controlled by different configuration options: prompts, tracebacks, as | |
|
40 | you type in the terminal and the object introspection system which | |
|
39 | controlled by different configuration options: prompts, tracebacks, "as | |
|
40 | you type" in the terminal, and the object introspection system which | |
|
41 | 41 | passes large sets of data through a pager. There are various way to |
|
42 | 42 | change the colors. |
|
43 | 43 | |
|
44 | 44 | We can distinguish the coloration into 2 main categories: |
|
45 | 45 | |
|
46 | - The one that affect only the terminal client. | |
|
47 | - The ones that also affect client connected through the Jupyter | |
|
46 | - The one that affects only the terminal client. | |
|
47 | - The ones that also affect clients connected through the Jupyter | |
|
48 | 48 | protocol. |
|
49 | 49 | |
|
50 | Traceback, debugger, and pager are highlighted kernel-side so fall | |
|
51 |
into the second category |
|
|
50 | Traceback, debugger, and pager are highlighted kernel-side so they fall | |
|
51 | into the second category. For historical reasons they are often | |
|
52 | 52 | governed by a ``colors`` attribute or configuration option that can |
|
53 | 53 | take one of 3 case insensitive values: ``NoColors``, ``Linux`` and |
|
54 | 54 | ``LightBG``. |
|
55 | 55 | |
|
56 |
Colors that affect only the terminal client are governed |
|
|
56 | Colors that affect only the terminal client are governed mainly by | |
|
57 | 57 | ``TerminalInteractiveShell.highlight_style`` taking the name of a |
|
58 | 58 | ``Pygments`` style. |
|
59 | 59 | |
|
60 | 60 | As of IPython 5.0 the color configuration works as follows: |
|
61 | 61 | |
|
62 | 62 | - by default, ``TerminalInteractiveShell.highlight_style`` is set to |
|
63 |
``legacy`` which **try to** emulate the colors of IPython pre 5.0 |
|
|
63 | ``legacy`` which **trys to** emulate the colors of IPython pre 5.0 | |
|
64 | 64 | and respect the ``.color`` configuration option. |
|
65 |
The emulation is approximati |
|
|
66 |
(2.1) d |
|
|
65 | The emulation is an approximation of the current version of Pygments | |
|
66 | (2.1) and only supports extended ANSI escape sequence, hence the | |
|
67 | 67 | theme cannot adapt to your terminal custom mapping if you have |
|
68 | 68 | one. |
|
69 | 69 | |
|
70 | 70 | The last extra difference being that the "as you type" coloration |
|
71 | 71 | is present using the theme "default" if `color` is `LightBG`, and |
|
72 | 72 | using the theme "monokai" if `Linux`. |
|
73 | 73 | |
|
74 | 74 | - if ``TerminalInteractiveShell.highlight_style`` is set to any other |
|
75 | 75 | themes, this theme is used for "as you type" highlighting. The |
|
76 | 76 | prompt highlighting is then governed by |
|
77 | 77 | ``--TerminalInteractiveShell.highlighting_style_overrides`` |
|
78 | 78 | |
|
79 | 79 | As a summary, by default IPython 5.0 should mostly behave unchanged |
|
80 | 80 | from IPython 4.x and before. Use |
|
81 | 81 | ``TerminalInteractiveShell.highlight_style`` and |
|
82 | 82 | ``--TerminalInteractiveShell.highlighting_style_overrides`` for extra |
|
83 | 83 | flexibility. |
|
84 | 84 | |
|
85 | 85 | With default configuration `--colors=[nocolors|linux|ightbg]` as well |
|
86 | 86 | as the `%colors` magic should behave identically as before. |
|
87 | 87 | |
|
88 | 88 | |
|
89 | 89 | Colors in the pager |
|
90 | 90 | ------------------- |
|
91 | 91 | |
|
92 | 92 | On some systems, the default pager has problems with ANSI colour codes. |
|
93 | 93 | To configure your default pager to allow these: |
|
94 | 94 | |
|
95 | 95 | 1. Set the environment PAGER variable to ``less``. |
|
96 | 96 | 2. Set the environment LESS variable to ``-r`` (plus any other options |
|
97 | 97 | you always want to pass to less by default). This tells less to |
|
98 | 98 | properly interpret control sequences, which is how color |
|
99 | 99 | information is given to your terminal. |
|
100 | 100 | |
|
101 | 101 | |
|
102 | 102 | |
|
103 | 103 | |
|
104 | 104 | .. _editors: |
|
105 | 105 | |
|
106 | 106 | Editor configuration |
|
107 | 107 | ==================== |
|
108 | 108 | |
|
109 | 109 | IPython can integrate with text editors in a number of different ways: |
|
110 | 110 | |
|
111 | 111 | * Editors (such as `(X)Emacs`_, vim_ and TextMate_) can |
|
112 | 112 | send code to IPython for execution. |
|
113 | 113 | |
|
114 | 114 | * IPython's ``%edit`` magic command can open an editor of choice to edit |
|
115 | 115 | a code block. |
|
116 | 116 | |
|
117 | 117 | The %edit command (and its alias %ed) will invoke the editor set in your |
|
118 | 118 | environment as :envvar:`EDITOR`. If this variable is not set, it will default |
|
119 | 119 | to vi under Linux/Unix and to notepad under Windows. You may want to set this |
|
120 | 120 | variable properly and to a lightweight editor which doesn't take too long to |
|
121 | 121 | start (that is, something other than a new instance of Emacs). This way you |
|
122 | 122 | can edit multi-line code quickly and with the power of a real editor right |
|
123 | 123 | inside IPython. |
|
124 | 124 | |
|
125 | 125 | You can also control the editor by setting :attr:`TerminalInteractiveShell.editor` |
|
126 | 126 | in :file:`ipython_config.py`. |
|
127 | 127 | |
|
128 | 128 | Vim |
|
129 | 129 | --- |
|
130 | 130 | |
|
131 | 131 | Paul Ivanov's `vim-ipython <https://github.com/ivanov/vim-ipython>`_ provides |
|
132 | 132 | powerful IPython integration for vim. |
|
133 | 133 | |
|
134 | 134 | .. _emacs: |
|
135 | 135 | |
|
136 | 136 | (X)Emacs |
|
137 | 137 | -------- |
|
138 | 138 | |
|
139 | 139 | If you are a dedicated Emacs user, and want to use Emacs when IPython's |
|
140 | 140 | ``%edit`` magic command is called you should set up the Emacs server so that |
|
141 | 141 | new requests are handled by the original process. This means that almost no |
|
142 | 142 | time is spent in handling the request (assuming an Emacs process is already |
|
143 | 143 | running). For this to work, you need to set your EDITOR environment variable |
|
144 | 144 | to 'emacsclient'. The code below, supplied by Francois Pinard, can then be |
|
145 | 145 | used in your :file:`.emacs` file to enable the server: |
|
146 | 146 | |
|
147 | 147 | .. code-block:: common-lisp |
|
148 | 148 | |
|
149 | 149 | (defvar server-buffer-clients) |
|
150 | 150 | (when (and (fboundp 'server-start) (string-equal (getenv "TERM") 'xterm)) |
|
151 | 151 | (server-start) |
|
152 | 152 | (defun fp-kill-server-with-buffer-routine () |
|
153 | 153 | (and server-buffer-clients (server-done))) |
|
154 | 154 | (add-hook 'kill-buffer-hook 'fp-kill-server-with-buffer-routine)) |
|
155 | 155 | |
|
156 | 156 | Thanks to the work of Alexander Schmolck and Prabhu Ramachandran, |
|
157 | 157 | currently (X)Emacs and IPython get along very well in other ways. |
|
158 | 158 | |
|
159 | 159 | With (X)EMacs >= 24, You can enable IPython in python-mode with: |
|
160 | 160 | |
|
161 | 161 | .. code-block:: common-lisp |
|
162 | 162 | |
|
163 | 163 | (require 'python) |
|
164 | 164 | (setq python-shell-interpreter "ipython") |
|
165 | 165 | |
|
166 | 166 | .. _`(X)Emacs`: http://www.gnu.org/software/emacs/ |
|
167 | 167 | .. _TextMate: http://macromates.com/ |
|
168 | 168 | .. _vim: http://www.vim.org/ |
General Comments 0
You need to be logged in to leave comments.
Login now