forked from akkana/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtermcolors
executable file
·32 lines (27 loc) · 1.2 KB
/
termcolors
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 python
import sys
# Display the colors available in a terminal.
# This was documented as 16-color mode, but actually anything over 8 fails.
colornames = [ "black", "red", "green", "yellow",
"blue", "magenta", "cyan", "white" ]
print "16-color mode (actually only 8):"
print " %14ss %14s %14ss" % ('normal', 'inverse', 'bright')
for color in range(0, 8) :
# Print the color in normal and inverse video:
for prefix in [3, 4] :
print "\033[0;%s%dm%2d%2d%2d %-8s\033[m" % (prefix, color,
color, color, color,
colornames[color]),
# Also print the "bright" version of the color:
for prefix in [3] :
print "\033[0;%s%d;1m%2d%2d%2d %-8s\033[m" % (prefix, color,
color, color, color,
colornames[color]),
print
sys.exit(0)
# Programs like ls and vim use the first 16 colors of the 256-color palette.
print "256-color mode:"
for color in range(0, 256) :
for i in range(0, 3) :
print "\033[38;5;%sm%03s\033[m" % (str(color), str(color)),
print