Skip to content

Instantly share code, notes, and snippets.

@davividal
Created August 14, 2015 13:24
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 davividal/350f820c16e0a0a5e228 to your computer and use it in GitHub Desktop.
Save davividal/350f820c16e0a0a5e228 to your computer and use it in GitHub Desktop.
# Copied from http://jbisbee.blogspot.com.br/2013/07/add-history-and-tab-completion-to.html
try:
import readline
import rlcompleterimport 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