Show More
@@ -227,6 +227,7 b' class InteractiveShell(Configurable, Magic):' | |||
|
227 | 227 | # These are relatively independent and stateless |
|
228 | 228 | self.init_ipython_dir(ipython_dir) |
|
229 | 229 | self.init_instance_attrs() |
|
230 | self.init_environment() | |
|
230 | 231 | |
|
231 | 232 | # Create namespaces (user_ns, user_global_ns, etc.) |
|
232 | 233 | self.init_create_namespaces(user_ns, user_global_ns) |
@@ -396,6 +397,10 b' class InteractiveShell(Configurable, Magic):' | |||
|
396 | 397 | # interactive statements or whole blocks. |
|
397 | 398 | self.input_splitter = IPythonInputSplitter() |
|
398 | 399 | |
|
400 | def init_environment(self): | |
|
401 | """Any changes we need to make to the user's environment.""" | |
|
402 | pass | |
|
403 | ||
|
399 | 404 | def init_encoding(self): |
|
400 | 405 | # Get system encoding at startup time. Certain terminals (like Emacs |
|
401 | 406 | # under Win32 have it set to None, and we need to have a known valid |
@@ -1869,7 +1874,7 b' class InteractiveShell(Configurable, Magic):' | |||
|
1869 | 1874 | Parameters |
|
1870 | 1875 | ---------- |
|
1871 | 1876 | cmd : str |
|
1872 | Command to execute (can not end in '&', as bacground processes are | |
|
1877 | Command to execute (can not end in '&', as background processes are | |
|
1873 | 1878 | not supported. |
|
1874 | 1879 | split : bool, optional |
|
1875 | 1880 |
@@ -577,7 +577,6 b' Currently the magic system has the following functions:\\n"""' | |||
|
577 | 577 | """Provide extra detailed information about an object. |
|
578 | 578 | |
|
579 | 579 | '%pinfo2 object' is just a synonym for object?? or ??object.""" |
|
580 | print 'pinfo2 par: <%s>' % parameter_s # dbg | |
|
581 | 580 | self.shell._inspect('pinfo', parameter_s, detail_level=1, |
|
582 | 581 | namespaces=namespaces) |
|
583 | 582 | |
@@ -2509,6 +2508,7 b' Defaulting color scheme to \'NoColor\'"""' | |||
|
2509 | 2508 | # atab.append(k, v[0]) |
|
2510 | 2509 | |
|
2511 | 2510 | print "Total number of aliases:", len(aliases) |
|
2511 | sys.stdout.flush() | |
|
2512 | 2512 | return aliases |
|
2513 | 2513 | |
|
2514 | 2514 | # Now try to define a new one |
@@ -2917,11 +2917,8 b' Defaulting color scheme to \'NoColor\'"""' | |||
|
2917 | 2917 | except ValueError: |
|
2918 | 2918 | var,cmd = '','' |
|
2919 | 2919 | # If all looks ok, proceed |
|
2920 | out = self.shell.getoutput(cmd) | |
|
2921 | if opts.has_key('l'): | |
|
2922 | out = SList(out.splitlines()) | |
|
2923 | else: | |
|
2924 | out = LSString(out) | |
|
2920 | split = 'l' in opts | |
|
2921 | out = self.shell.getoutput(cmd, split=split) | |
|
2925 | 2922 | if opts.has_key('v'): |
|
2926 | 2923 | print '%s ==\n%s' % (var,pformat(out)) |
|
2927 | 2924 | if var: |
@@ -2965,9 +2962,7 b' Defaulting color scheme to \'NoColor\'"""' | |||
|
2965 | 2962 | system commands.""" |
|
2966 | 2963 | |
|
2967 | 2964 | if parameter_s: |
|
2968 |
|
|
|
2969 | if out is not None: | |
|
2970 | return SList(out.splitlines()) | |
|
2965 | return self.shell.getoutput(parameter_s) | |
|
2971 | 2966 | |
|
2972 | 2967 | def magic_r(self, parameter_s=''): |
|
2973 | 2968 | """Repeat previous input. |
@@ -24,6 +24,7 b' import re' | |||
|
24 | 24 | from IPython.core.interactiveshell import ( |
|
25 | 25 | InteractiveShell, InteractiveShellABC |
|
26 | 26 | ) |
|
27 | from IPython.core import page | |
|
27 | 28 | from IPython.core.displayhook import DisplayHook |
|
28 | 29 | from IPython.core.macro import Macro |
|
29 | 30 | from IPython.core.payloadpage import install_payload_page |
@@ -78,6 +79,19 b' class ZMQInteractiveShell(InteractiveShell):' | |||
|
78 | 79 | |
|
79 | 80 | displayhook_class = Type(ZMQDisplayHook) |
|
80 | 81 | |
|
82 | def init_environment(self): | |
|
83 | """Configure the user's environment. | |
|
84 | ||
|
85 | """ | |
|
86 | env = os.environ | |
|
87 | # These two ensure 'ls' produces nice coloring on BSD-derived systems | |
|
88 | env['TERM'] = 'xterm-color' | |
|
89 | env['CLICOLOR'] = '1' | |
|
90 | # Since normal pagers don't work at all (over pexpect we don't have | |
|
91 | # single-key control of the subprocess), try to disable paging in | |
|
92 | # subprocesses as much as possible. | |
|
93 | env['PAGER'] = 'cat' | |
|
94 | env['GIT_PAGER'] = 'cat' | |
|
81 | 95 | |
|
82 | 96 | def auto_rewrite_input(self, cmd): |
|
83 | 97 | """Called to show the auto-rewritten input for autocall and friends. |
@@ -485,5 +499,37 b' class ZMQInteractiveShell(InteractiveShell):' | |||
|
485 | 499 | raise NotImplementedError( |
|
486 | 500 | 'pylab support must be enabled in command line options.') |
|
487 | 501 | |
|
502 | # A few magics that are adapted to the specifics of using pexpect and a | |
|
503 | # remote terminal | |
|
504 | ||
|
505 | def magic_clear(self, arg_s): | |
|
506 | """Clear the terminal.""" | |
|
507 | if os.name == 'posix': | |
|
508 | self.shell.system("clear") | |
|
509 | else: | |
|
510 | self.shell.system("cls") | |
|
511 | ||
|
512 | if os.name == 'nt': | |
|
513 | # This is the usual name in windows | |
|
514 | magic_cls = magic_clear | |
|
515 | ||
|
516 | # Terminal pagers won't work over pexpect, but we do have our own pager | |
|
517 | ||
|
518 | def magic_less(self, arg_s): | |
|
519 | """Show a file through the pager. | |
|
520 | ||
|
521 | Files ending in .py are syntax-highlighted.""" | |
|
522 | cont = open(arg_s).read() | |
|
523 | if arg_s.endswith('.py'): | |
|
524 | cont = self.shell.pycolorize(cont) | |
|
525 | page.page(cont) | |
|
526 | ||
|
527 | magic_more = magic_less | |
|
528 | ||
|
529 | # Man calls a pager, so we also need to redefine it | |
|
530 | if os.name == 'posix': | |
|
531 | def magic_man(self, arg_s): | |
|
532 | """Find the man page for the given command and display in pager.""" | |
|
533 | page.page(self.shell.getoutput('man %s' % arg_s, split=False)) | |
|
488 | 534 | |
|
489 | 535 | InteractiveShellABC.register(ZMQInteractiveShell) |
General Comments 0
You need to be logged in to leave comments.
Login now