Created
July 9, 2013 02:36
-
-
Save arowser/5954256 to your computer and use it in GitHub Desktop.
Add History and Tab Completion to the Default Python Shell
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
# ~/.bashrc | |
export PYTHONSTARTUP=$HOME/.pythonstartup.py | |
# ~/.pythonstartup.py | |
try: | |
import readline | |
import rlcompleter | |
import atexit | |
import os | |
except ImportError: | |
print "Python shell enhancement modules not available." | |
else: | |
histfile = os.path.join(os.environ["HOME"], ".pythonhistory") | |
import rlcompleter | |
readline.parse_and_bind("tab: complete") | |
if os.path.isfile(histfile): | |
readline.read_history_file(histfile) | |
atexit.register(readline.write_history_file, histfile) | |
del os, histfile, readline, rlcompleter, atexit | |
print "Python shell history and tab completion are enabled." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment