Skip to content

Instantly share code, notes, and snippets.

@pavelpy
Created July 13, 2018 08:30
Show Gist options
  • Save pavelpy/d60f4b7dd75b176c9eddf66f39e8da13 to your computer and use it in GitHub Desktop.
Save pavelpy/d60f4b7dd75b176c9eddf66f39e8da13 to your computer and use it in GitHub Desktop.
export PYTHONSTARTUP=$HOME/.python-startup.py
import os
import readline
import rlcompleter
import atexit
history_file = os.path.join(os.environ['HOME'], '.python_history')
try:
readline.read_history_file(history_file)
except IOError:
pass
# Turn on Autocomplete
readline.parse_and_bind("tab: complete")
# Limit the number of entries saved
readline.set_history_length(1000)
# Create history file on exit if it doesn't already exist
atexit.register(readline.write_history_file, history_file)
# Remove all variables
del os, readline, rlcompleter, atexit, history_file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment