forked from akkana/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtermcolors
executable file
·38 lines (33 loc) · 1.47 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
33
34
35
36
37
38
#! /usr/bin/env python
import sys
# Display the colors available in a terminal.
# given any argument, it'll display 256-color mode as well as 16-color mode.
# Programs like ls and vim use the first 16 colors of the 256-color palette.
# This was documented as 16-color mode, but actually anything over 8 fails.
if len(sys.argv) > 1:
print("256-color mode:")
for color in range(0, 256) :
line = ""
for i in range(0, 3) :
line += "\033[38;5;%sm%03s\033[m" % (str(color), str(color))
print(line)
print()
print("16-color mode (actually only 8):")
else:
print("16-color mode (actually only 8): use -256 to usee more colors.")
colornames = [ "black", "red", "green", "yellow",
"blue", "magenta", "cyan", "white" ]
print(" %14ss %14s %14ss" % ('normal', 'inverse', 'bright'))
for color in range(0, 8) :
line = ""
# Print the color in normal and inverse video:
for prefix in [3, 4] :
line += "\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] :
line += "\033[0;%s%d;1m%2d%2d%2d %-8s\033[m " % (prefix, color,
color, color, color,
colornames[color])
print(line)