Created
August 31, 2016 10:21
-
-
Save ygbourhis/7fec9396a995442591163112c17dadb1 to your computer and use it in GitHub Desktop.
This file contains 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
#!/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