Skip to content

Instantly share code, notes, and snippets.

@flashingpumpkin
Last active December 17, 2015 07:58
Show Gist options
  • Select an option

  • Save flashingpumpkin/5576233 to your computer and use it in GitHub Desktop.

Select an option

Save flashingpumpkin/5576233 to your computer and use it in GitHub Desktop.
export PYTHONSTARTUP=/etc/profile.d/pythonrc.py
#!/usr/bin/env python
import os, sys
import math, random
import atexit
import rlcompleter, readline
histfile = '%s/.python_history' % os.environ['HOME']
max_size_bytes = 1000000
max_size_lines = 10000
if not os.path.isfile(histfile):
with open(histfile, 'w'):
pass
def writehist():
global histfile
global max_size_lines
global readline
readline.set_history_length(max_size_lines)
readline.write_history_file(histfile)
if sys.platform == 'darwin':
readline.parse_and_bind ("bind ^I rl_complete")
else:
readline.parse_and_bind("tab: complete")
readline.read_history_file(histfile)
atexit.register(writehist)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment