equal
deleted
inserted
replaced
|
1 # -*- mode: python -*- |
|
2 # Add auto-completion and a stored history file of commands to your Python |
|
3 # interactive interpreter. Requires Python 2.0+, readline. Autocomplete is |
|
4 # bound to the Esc key by default (you can change it - see readline docs). |
|
5 # |
|
6 # Store the file in ~/.pystartup, and set an environment variable to point |
|
7 # to it: "export PYTHONSTARTUP=~/.pystartup" in bash. |
|
8 |
|
9 import atexit |
|
10 import os |
|
11 import readline |
|
12 import rlcompleter |
|
13 |
|
14 historyPath = os.path.expanduser("~/.pyhistory") |
|
15 |
|
16 def save_history(historyPath=historyPath): |
|
17 import readline |
|
18 readline.write_history_file(historyPath) |
|
19 |
|
20 if os.path.exists(historyPath): |
|
21 readline.read_history_file(historyPath) |
|
22 |
|
23 atexit.register(save_history) |
|
24 del os, atexit, readline, rlcompleter, save_history, historyPath |
|
25 |