Skip to content

Instantly share code, notes, and snippets.

@ygbourhis
Created August 31, 2016 10:21
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 ygbourhis/7fec9396a995442591163112c17dadb1 to your computer and use it in GitHub Desktop.
Save ygbourhis/7fec9396a995442591163112c17dadb1 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
'''
Save this file and add the following line to your ~/.bashrc"
export PYTHONSTARTUP="$HOME/.pythonrc"
'''
def run_from_ipython():
try:
__IPYTHON__
return True
except NameError:
return False
if not run_from_ipython():
try:
import readline
except ImportError:
print "Module readline not available"
else:
import atexit
import os
import rlcompleter
histfile = os.path.join(os.path.expanduser("~"), ".pythonhist")
try:
readline.read_history_file(histfile)
except IOError:
pass
readline.parse_and_bind("set show-all-if-ambiguous on")
readline.parse_and_bind("tab: complete")
atexit.register(readline.write_history_file, histfile)
del histfile, os, readline, rlcompleter
else:
del run_from_ipython
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment