Skip to content

watch: Support bright colors

Nipunn Koorapati requested to merge nipunn1313/procps:watch_colors2 into master

Depends on !106 (closed)

image

nipunn@nipunn-desk2:~/src/procps$ cat colors.py
#!/usr/bin/env python3
# Ported to Python from http://www.vim.org/scripts/script.php?script_id=1349

print("Color indexes should be drawn in bold text of the same color.")

colored = [0] + [0x5f + 40 * n for n in range(0, 5)]
colored_palette = [
	"%02x/%02x/%02x" % (r, g, b)
	for r in colored
	for g in colored
	for b in colored
]

grayscale = [0x08 + 10 * n for n in range(0, 24)]
grayscale_palette = [
	"%02x/%02x/%02x" % (a, a, a)
	for a in grayscale
]

for ansi_range in [range(30, 38), range(90, 98)]:
    for color in ansi_range:
        print("\033[%smANSI %s\033[0m " % (color, color), end="")
    print()

normal = "\033[38;5;%sm"
bold = "\033[1;38;5;%sm"
reset = "\033[0m"

for (i, color) in enumerate(colored_palette + grayscale_palette, 0):
	index = (bold + "%4s" + reset) % (i, str(i) + ':')
	hex   = (normal + "%s" + reset) % (i, color)
	newline = '\n' if i % 6 == 3 else ''
	print(index, hex, newline,end="")
Edited by Nipunn Koorapati

Merge request reports