# From Randall Hopper
- if _term in term:
- if background == 'dark':
- ps1_color = '3' # yellow
- stdout_color = '7' # bold white
- else:
- ps1_color = '4' # blue
- stdout_color = '0' # bold black
for _term in ['linux', 'rxvt', 'screen', 'term', 'vt100']:
+ if _term not in term:
+ continue
+
+ if background == 'dark':
+ ps1_color = '3' # yellow
+ stdout_color = '7' # bold white
+ else:
+ ps1_color = '4' # blue
+ stdout_color = '0' # bold black
- sys.ps1 = '\001\033[3%sm\002>>>\001\033[0m\002 ' % ps1_color
- sys.ps2 = '\001\033[1;32m\002...\001\033[0m\002 ' # bold green
+ sys.ps1 = '\001\033[3%sm\002>>>\001\033[0m\002 ' % ps1_color
+ sys.ps2 = '\001\033[1;32m\002...\001\033[0m\002 ' # bold green
- # From Denis Otkidach
+ # From Denis Otkidach
- class ColoredFile:
- def __init__(self, fp, begin, end='\033[0m'): # reset all attributes
- self.__fp = fp
- self.__begin = begin
- self.__end = end
+ class ColoredFile:
+ def __init__(self, fp, begin, end='\033[0m'): # reset all attributes
+ self.__fp = fp
+ self.__begin = begin
+ self.__end = end
- def write(self, s):
- self.__fp.write(self.__begin+s+self.__end)
+ def write(self, s):
+ self.__fp.write(self.__begin+s+self.__end)
- def writelines(self, lines):
- map(self.write, lines)
+ def writelines(self, lines):
+ map(self.write, lines)
- def __getattr__(self, attr):
- return getattr(self.__fp, attr)
+ def __getattr__(self, attr):
+ return getattr(self.__fp, attr)
- sys.stdout = ColoredFile(sys.stdout, '\033[1;3%sm' % stdout_color)
- sys.stderr = ColoredFile(sys.stderr, '\033[31m') # red
+ sys.stdout = ColoredFile(sys.stdout, '\033[1;3%sm' % stdout_color)
+ sys.stderr = ColoredFile(sys.stderr, '\033[31m') # red
- break
+ break
try:
import locale