-
Notifications
You must be signed in to change notification settings - Fork 0
/
.pythonrc
30 lines (25 loc) · 854 Bytes
/
.pythonrc
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
try:
import atexit
import os
import readline
import rlcompleter
except ImportError as e:
print("Module not available: " + str(e))
else:
import readline
# Add tab-completion
if 'libedit' in readline.__doc__:
# osx compatibility mode
readline.parse_and_bind("bind ^I rl_complete")
else:
# everywhere else
readline.parse_and_bind("tab: complete")
# Save history for future python interpreter invocations
historyPath = os.path.expanduser("~/.pyhistory")
def save_history(historyPath=historyPath):
readline.write_history_file(historyPath)
# Read the history from disk
if os.path.exists(historyPath):
readline.read_history_file(historyPath)
# Register that save_history is called when the python intepreter exits
atexit.register(save_history)