]> code.delx.au - dotfiles/blob - .pythonrc.py
Fixed screen ^H issues in a nicer way
[dotfiles] / .pythonrc.py
1 #!/usr/bin/env python
2
3 # Useful things to have
4 from __future__ import division
5 from math import *
6 import sys, os, re, math
7
8 # Readline completion of everything :)
9 import rlcompleter, readline, atexit
10 defaultCompleter = rlcompleter.Completer()
11
12 historyPath = os.path.expanduser("~/.pyhistory")
13
14 def myCompleter(text, state):
15 if text.strip() == "" and state == 0:
16 return text + "\t"
17 else:
18 return defaultCompleter.complete(text, state)
19
20 def save_history(historyPath=historyPath):
21 import readline
22 readline.write_history_file(historyPath)
23
24 readline.set_completer(myCompleter)
25 readline.parse_and_bind("tab: complete")
26
27 if os.path.exists(historyPath):
28 readline.read_history_file(historyPath)
29
30 atexit.register(save_history)
31
32 del rlcompleter, readline, atexit
33