-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.pythonrc.py
37 lines (26 loc) · 835 Bytes
/
.pythonrc.py
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
37
import atexit
import os
import readline
import rlcompleter
import sys
default_completer = rlcompleter.Completer(locals())
histfile = os.path.expanduser('~/.pyhistory')
histsize = 1000
def my_completer(text, state):
if text.strip() == '' and state == 0:
return text + '\t'
else:
return default_completer.complete(text, state)
def save_history(histfile=histfile, histsize=histsize):
import readline
readline.set_history_length(histsize)
readline.write_history_file(histfile)
readline.set_completer(my_completer)
if 'libedit' in readline.__doc__:
readline.parse_and_bind('bind ^I rl_complete')
else:
readline.parse_and_bind('tab: complete')
if os.path.exists(histfile) and sys.version_info.major == 3:
readline.read_history_file(histfile)
atexit.register(save_history)
del rlcompleter, readline, atexit