-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.pythonrc.py
36 lines (27 loc) · 839 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
#!/usr/bin/env python
# vim:set nolist noet tw=0 ts=4 sw=4 sts=4:
# Useful things to have
from __future__ import division
from math import *
import sys, os, re, math
# Readline completion of everything :)
import rlcompleter, readline, atexit
defaultCompleter = rlcompleter.Completer()
historyPath = os.path.expanduser("~/.pyhistory")
def myCompleter(text, state):
if text.strip() == "":
if state == 0:
return text + "\t"
else:
return None
else:
return defaultCompleter.complete(text, state)
def save_history(historyPath=historyPath):
import readline
readline.write_history_file(historyPath)
readline.set_completer(myCompleter)
readline.parse_and_bind("tab: complete")
if os.path.exists(historyPath):
readline.read_history_file(historyPath)
atexit.register(save_history)
del rlcompleter, readline, atexit