Skip to content

Instantly share code, notes, and snippets.

@redraiment
Created October 11, 2013 12:40
Show Gist options
  • Save redraiment/6933951 to your computer and use it in GitHub Desktop.
Save redraiment/6933951 to your computer and use it in GitHub Desktop.
Python启动文件,为REPL添加自动补全以及历史功能
import rlcompleter
import readline
import atexit
import os
# http://stackoverflow.com/questions/7116038/python-tab-completion-mac-osx-10-7-lion
if 'libedit' in readline.__doc__:
readline.parse_and_bind('bind ^I rl_complete')
else:
readline.parse_and_bind('tab: complete')
histfile = os.path.join(os.environ['HOME'], '.emacs.d', 'history', 'python')
try:
readline.read_history_file(histfile)
except IOError:
pass
atexit.register(readline.write_history_file, histfile)
del readline, rlcompleter, histfile, os
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment