Skip to content

Instantly share code, notes, and snippets.

@disorder
Forked from twneale/gist:5245670
Last active January 14, 2018 12:37
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 disorder/40ff4a9b8592064e311ac8065d2dd442 to your computer and use it in GitHub Desktop.
Save disorder/40ff4a9b8592064e311ac8065d2dd442 to your computer and use it in GitHub Desktop.
.pythonrc file that adds command history and tab completion to my python shell.
'''
Save this file and add the following line to your ~/.bashrc"
export PYTHONSTARTUP="$HOME/.pythonrc"
'''
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
readline.parse_and_bind("tab: complete")
readline.set_history_length(1000)
atexit.register(readline.write_history_file, history_file)
del readline, rlcompleter, atexit, history_file
# In addition to os, import some useful things:
import re
import sys
from collections import *
from itertools import *
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment