Created
October 11, 2013 12:40
-
-
Save redraiment/6933951 to your computer and use it in GitHub Desktop.
Python启动文件,为REPL添加自动补全以及历史功能
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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