Created
January 4, 2016 08:54
-
-
Save draganHR/4be2bb5e5a28fe6c2408 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
""" | |
Instructions: | |
- Put this file at ~/.pythonrc.py | |
- Add `export PYTHONSTARTUP=~/.pythonrc.py` to ~/.bashrc | |
Source: | |
- https://github.com/dag/dotfiles/blob/master/python/.pythonrc | |
- https://github.com/dcramer/dotfiles/blob/master/python/pythonrc.py | |
""" | |
import os | |
import rlcompleter | |
import readline | |
import atexit | |
readline.parse_and_bind('tab: complete') | |
readline.parse_and_bind('set editing-mode vi') | |
history = os.path.expanduser("~/.python_history") | |
if os.path.exists(history): | |
try: | |
readline.read_history_file(history) | |
except IOError: | |
print("Failed to read %r: %s" % (history, e)) | |
readline.set_history_length(1024 * 5) | |
def write_history(history): | |
def wrapped(): | |
import readline | |
readline.write_history_file(history) | |
return wrapped | |
atexit.register(write_history(history)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment