1
2
3
4
5 import os,sys
6
7 havecolor=1
8 dotitles=1
9
10 codes={}
11 codes["reset"]="\x1b[0m"
12 codes["bold"]="\x1b[01m"
13
14 codes["teal"]="\x1b[36;06m"
15 codes["turquoise"]="\x1b[36;01m"
16
17 codes["fuscia"]="\x1b[35;01m"
18 codes["purple"]="\x1b[35;06m"
19
20 codes["blue"]="\x1b[34;01m"
21 codes["darkblue"]="\x1b[34;06m"
22
23 codes["green"]="\x1b[32;01m"
24 codes["darkgreen"]="\x1b[32;06m"
25
26 codes["yellow"]="\x1b[33;01m"
27 codes["brown"]="\x1b[33;06m"
28
29 codes["red"]="\x1b[31;01m"
30 codes["darkred"]="\x1b[31;06m"
31
33 if havecolor and dotitles and os.environ.has_key("TERM"):
34 myt=os.environ["TERM"]
35 if myt in ["xterm","Eterm","aterm","rxvt"]:
36 sys.stderr.write("\x1b]1;\x07\x1b]2;"+str(mystr)+"\x07")
37 sys.stderr.flush()
38
43
44
46 "turn off title setting"
47 dotitles=0
48
54
57
58 -def ctext(color,text):
59 return codes[ctext]+text+codes["reset"]
60
65
72
77
82
87
94
99