Source

dotfiles / pythonrc

#!/usr/bin/env python
def do_rc():
    # Put everything inside this function so we don't muck up the global
    # namespace AND we don't have to delete a bunch of things.
    import os
    import sys

    # Add the 'good' pdb and rlcomplete to the path
    sys.path.insert(0, os.getenv("HOME") + "/.python/")

    import rlcompleter_ng
    rlcompleter_ng.setup()

    import readline
    histfile = os.path.expanduser("~/.pyhist")
    if os.path.exists(histfile):
        readline.read_history_file(histfile)
    readline.parse_and_bind("tab: complete")

    import atexit
    atexit.register(readline.write_history_file, histfile)

do_rc()

del do_rc