-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathpythonrc.py
More file actions
36 lines (25 loc) · 800 Bytes
/
pythonrc.py
File metadata and controls
36 lines (25 loc) · 800 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python
# Inspired by https://github.com/dag/dotfiles/blob/master/python/.pythonrc
from __future__ import print_function
import os
def setup_history():
import readline
readline.parse_and_bind('tab: complete')
history = os.path.expanduser("~/.pythonhist")
if os.path.exists(history):
try:
readline.read_history_file(history)
except IOError as e:
print("Failed to read %r: %s" % (history, e))
readline.set_history_length(1024 * 5)
import atexit
atexit.register(write_history(history))
def write_history(history):
def wrapped():
import readline
readline.write_history_file(history)
return wrapped
try:
setup_history()
except ImportError:
import traceback; traceback.print_exc()