Last active
June 2, 2019 21:00
-
-
Save cellcoresystems/5351392d2f0475af52ee514ec52a34d6 to your computer and use it in GitHub Desktop.
pythonrc file
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
# .pythonrc | |
# | |
# to activate put this in your .bashrc or .zshrc file | |
# export PYTHONSTARTUP=~/.pythonrc | |
# | |
# reminder: does not work work with python -i | |
# you have to use this in every script: | |
# | |
# import os | |
# if os.path.isfile(os.environ['PYTHONSTARTUP']): | |
# exec(open(os.environ['PYTHONSTARTUP']).read()) | |
import readline | |
import rlcompleter | |
import atexit | |
import os | |
# tab completion | |
readline.parse_and_bind('tab: complete') | |
# history file | |
histfile = os.path.join(os.environ['HOME'], '.pythonhistory') | |
try: | |
readline.read_history_file(histfile) | |
readline.set_history_length(10000) | |
except IOError: | |
pass | |
# list history | |
def history(): | |
for i in range(readline.get_current_history_length()): | |
print(readline.get_history_item(i + 1)) | |
atexit.register(readline.write_history_file, histfile) | |
#del os, histfile, readline, rlcompleter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment