-
Notifications
You must be signed in to change notification settings - Fork 746
/
colortest.py
executable file
·32 lines (24 loc) · 846 Bytes
/
colortest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python2
import sys
ESCAPE = chr(27)
def fg(color):
return ESCAPE + '[38;5;{0}m'.format(color)
def bg(color):
return ESCAPE + '[48;5;{0}m'.format(color)
def reset():
return ESCAPE + '[48;0m'
if __name__ == "__main__":
if len(sys.argv) < 6:
print 'Usage: colortest.py fg_start fg_end bg_start bg_end test_string'
sys.exit(1)
fg_start, fg_end, bg_start, bg_end = map(int, sys.argv[1:5])
test_string = sys.argv[5]
print ' ' * len(str(bg_start)),
for fg_color in range(fg_start, fg_end + 1):
print ' ' * (len(test_string) - len(str(fg_color))), fg_color,
print
for bg_color in range(bg_start, bg_end + 1):
print bg_color, bg(bg_color),
for fg_color in range(fg_start, fg_end + 1):
print fg(fg_color), test_string,
print reset()