Skip to content

Instantly share code, notes, and snippets.

@cellcoresystems
Last active June 2, 2019 21:00
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 cellcoresystems/5351392d2f0475af52ee514ec52a34d6 to your computer and use it in GitHub Desktop.
Save cellcoresystems/5351392d2f0475af52ee514ec52a34d6 to your computer and use it in GitHub Desktop.
pythonrc file
# .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