diff --git a/IPython/Extensions/ipy_sane_defaults.py b/IPython/Extensions/ipy_sane_defaults.py new file mode 100644 index 0000000..424a097 --- /dev/null +++ b/IPython/Extensions/ipy_sane_defaults.py @@ -0,0 +1,60 @@ +""" Set default options for "reasonable use" + +Just import this module to get reasonable defaults for everything. + +These configurations used to be performed in ipythonrc (or ipythonrc.ini). +Therefore importing this in your config files makes ipython basically +ignore your ipythonrc. This is *not* imported by default, you need to import +this manually in one of your config files. + +You can further override these defaults in e.g. your ipy_user_config.py, +ipy_profile_PROFILENAME etc. + +""" + +import IPython.rlineimpl as readline +import IPython.ipapi +ip = IPython.ipapi.get() + +o = ip.options() + + +o.colors = "Linux" +o.color_info=1 +o.confirm_exit=1 +o.pprint=1 +o.multi_line_specials=1 +o.xmode="Context" + + +o.prompt_in1='In [\#]: ' +o.prompt_in2 =' .\D.: ' +o.prompt_out = 'Out[\#]: ' +o.prompts_pad_left=1 + +o.readline_remove_delims="-/~" +o.readline_merge_completions=1 + +o.readline = 1 + +rlopts = """\ +tab: complete +"\C-l": possible-completions +set show-all-if-ambiguous on +"\C-o": tab-insert +"\M-i": " " +"\M-o": "\d\d\d\d" +"\M-I": "\d\d\d\d" +"\C-r": reverse-search-history +"\C-s": forward-search-history +"\C-p": history-search-backward +"\C-n": history-search-forward +"\e[A": history-search-backward +"\e[B": history-search-forward +"\C-k": kill-line +"\C-u": unix-line-discard""" + +for cmd in rlopts.split('\n'): + readline.parse_and_bind(cmd) + + \ No newline at end of file diff --git a/IPython/UserConfig/ipy_profile_sh.py b/IPython/UserConfig/ipy_profile_sh.py index 227004f..610063a 100644 --- a/IPython/UserConfig/ipy_profile_sh.py +++ b/IPython/UserConfig/ipy_profile_sh.py @@ -13,6 +13,11 @@ compatibility) from IPython import ipapi import os,textwrap +# The import below effectively obsoletes your old-style ipythonrc[.ini], +# so consider yourself warned! + +import ipy_sane_defaults + def main(): ip = ipapi.get() o = ip.options() @@ -26,6 +31,9 @@ def main(): ip.ex("from path import path" ) except ImportError: pass + + ip.ex('import os') + ip.ex("def up(): os.chdir('..')") # Get pysh-like prompt for all profiles. diff --git a/IPython/UserConfig/ipy_user_conf.py b/IPython/UserConfig/ipy_user_conf.py index ea593ba..913fe28 100644 --- a/IPython/UserConfig/ipy_user_conf.py +++ b/IPython/UserConfig/ipy_user_conf.py @@ -9,57 +9,20 @@ ipython extensions you need here (see IPython/Extensions directory). Feel free to edit this file to customize your ipython experience. Note that as such this file does nothing, for backwards compatibility. -To enable this config file, uncomment the call to main() at the end. - -Try it out! +Consult e.g. file 'ipy_profile_sh.py' for an example of the things +you can do here. """ # Most of your config files and extensions will probably start with this import -from IPython import ipapi -import os -from IPython import Release - -import sys - +import IPython.ipapi +ip = IPython.ipapi.get() def main(): - ip = ipapi.get() o = ip.options() - # autocall to "full" mode (smart mode is default, I like full mode) - - o.autocall = 1 - - # Jason Orendorff's path class is handy to have in user namespace - # if you are doing shell-like stuff - try: - ip.ex("from path import path" ) - except ImportError: - pass - - # Get prompt with working dir - - o.prompt_in1= '\C_LightBlue[\C_LightCyan\Y1\C_LightBlue]\C_Green|\#> ' - o.prompt_in2= '\C_Green|\C_LightGreen\D\C_Green> ' - o.prompt_out= '<\#> ' - - # I like my banner minimal. - o.banner = "Py %s IPy %s\n" % (sys.version.split('\n')[0],Release.version) - - # make 'd' an alias for ls -F - - ip.magic('alias d ls -F --color=auto') - - # Make available all system commands through "rehashing" immediately. - # You can comment these lines out to speed up startup on very slow - # machines, and to conserve a bit of memory. Note that pysh profile does this - # automatically - - #if os.name=='posix': - # ip.magic('rehash') - #else: - # #slightly slower, but better results esp. with Windows - # ip.magic('rehashx') + # An example on how to set options + #o.autocall = 1 -#main() \ No newline at end of file +main() + \ No newline at end of file diff --git a/doc/ChangeLog b/doc/ChangeLog index 21dc59f..fa1103a 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,6 +1,11 @@ 2006-02-15 Ville Vainio * Magic.py: %Pprint works again + + * Extensions/ipy_sane_defaults.py: Provide everything provided + in default ipythonrc, to make it possible to have a completely empty + ipythonrc (and thus completely rc-file free configuration) + 2006-02-11 Fernando Perez