equal
deleted
inserted
replaced
4 # bound to the Esc key by default (you can change it - see readline docs). |
4 # bound to the Esc key by default (you can change it - see readline docs). |
5 # |
5 # |
6 # Store the file in ~/.pystartup, and set an environment variable to point |
6 # Store the file in ~/.pystartup, and set an environment variable to point |
7 # to it: "export PYTHONSTARTUP=~/.pystartup" in bash. |
7 # to it: "export PYTHONSTARTUP=~/.pystartup" in bash. |
8 |
8 |
|
9 import os |
|
10 import sys |
9 import atexit |
11 import atexit |
10 import os |
|
11 import readline |
12 import readline |
12 import rlcompleter |
13 import rlcompleter |
13 |
14 |
14 historyPath = os.path.expanduser("~/.pyhistory") |
15 historyPath = os.path.expanduser("~/.pyhistory") |
15 |
16 |
18 readline.write_history_file(historyPath) |
19 readline.write_history_file(historyPath) |
19 |
20 |
20 if os.path.exists(historyPath): |
21 if os.path.exists(historyPath): |
21 readline.read_history_file(historyPath) |
22 readline.read_history_file(historyPath) |
22 |
23 |
|
24 term_with_colors = ['xterm', 'xterm-color', 'xterm-256color', 'linux', 'screen', 'screen-256color', 'screen-bce'] |
|
25 if os.environ.get('TERM') in term_with_colors: |
|
26 green='\033[32m' |
|
27 red='\033[31m' |
|
28 reset='\033[0m' |
|
29 sys.ps1 = red + '>>> ' + reset |
|
30 sys.ps2 = green + '... ' + reset |
|
31 del term_with_colors |
|
32 |
23 atexit.register(save_history) |
33 atexit.register(save_history) |
24 del os, atexit, readline, rlcompleter, save_history, historyPath |
34 del os, sys, atexit, readline, rlcompleter, save_history, historyPath |
25 |
35 |