-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcolors.py
More file actions
24 lines (22 loc) · 748 Bytes
/
colors.py
File metadata and controls
24 lines (22 loc) · 748 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python
#
# A utility to print colored text to the shell.
# Probably doesn't work on Windows.
COLORS = {'red':'31',
'green': '32',
'yellow': '33',
'blue': '34',
'magenta': '35',
'cyan': '36',
'white': '37',
'reset': '39'}
def colorText(s,color):
# color should be a string from COLORS
return '\033[%sm%s\033[%sm'%(COLORS[color],s,COLORS['reset'])
def red(s): return colorText(s,'red')
def green(s): return colorText(s,'green')
def yellow(s): return colorText(s,'yellow')
def blue(s): return colorText(s,'blue')
def magenta(s): return colorText(s,'magenta')
def cyan(s): return colorText(s,'cyan')
def white(s): return colorText(s,'white')