Skip to content

Instantly share code, notes, and snippets.

@sigma
Created August 30, 2009 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sigma/178055 to your computer and use it in GitHub Desktop.
Save sigma/178055 to your computer and use it in GitHub Desktop.
ipy_user_conf.py
""" User configuration file for IPython """
# Most of your config files and extensions will probably start with this import
import IPython.ipapi
ip = IPython.ipapi.get()
import ipy_defaults
import os
def main():
import ipy_editors
ipy_editors.install_editor("emacsclient-cvs -t +$line $file")
o = ip.options
#o.autocall = 1
o.system_verbose = 0
import_all("os sys")
# -- prompt
# A different, more compact set of prompts from the default ones, that
# always show your current location in the filesystem:
o.prompt_in1 = r'\C_LightBlue[\C_LightCyan\Y2\C_LightBlue]\C_Normal\n\C_Green|\#>'
o.prompt_in2 = r'.\D: '
o.prompt_out = r'[\#] '
# for sane integer division that converts to float (1/2 == 0.5)
o.autoexec.append('from __future__ import division')
# For autoreloading of modules (%autoreload, %aimport)
import ipy_autoreload
import readline
readline.parse_and_bind('set completion-query-items 1000')
readline.parse_and_bind('set page-completions no')
import rlcompleter2
rlcompleter2.setup()
# this is needed since hachoir trashes sys.stdout and sys.stderr
import hachoir_core.config as config
config.unicode_stdout = False
# some config helper functions you can use
def import_all(modules):
""" Usage: import_all("os sys") """
for m in modules.split():
ip.ex("from %s import *" % m)
def execf(fname):
""" Execute a file in user namespace """
ip.ex('execfile("%s")' % os.path.expanduser(fname))
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment