Skip to content

Instantly share code, notes, and snippets.

@jpadilla
Last active April 7, 2018 16:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpadilla/6022163 to your computer and use it in GitHub Desktop.
Save jpadilla/6022163 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
@jpadilla
Copy link
Author

Can be used with Django shell_plus:

python manage.py shell_plus --use-pythonrc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment