如何在我的终端打印256色测试图案?
我想检查我的终端是否正确地支持256种颜色。
发布于 2016-09-05 09:39:30
我找到了贾斯汀·艾布拉姆斯写的GitHub上的Python脚本很不错,它还打印了颜色的六角码。
将脚本下载到当前工作目录
wget https://gist.githubusercontent.com/justinabrahms/1047767/raw/a79218b6ca8c1c04856968d2d202510a4f7ec215/colortest.py给它执行许可
chmod +x colortest.py运行它:
./colortest.py
下面是完整的脚本,以防链接腐烂:
#!/usr/bin/env python
# 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."
print
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
]
normal = "\033[38;5;%sm"
bold = "\033[1;38;5;%sm"
reset = "\033[0m"
for (i, color) in enumerate(colored_palette + grayscale_palette, 16):
index = (bold + "%4s" + reset) % (i, str(i) + ':')
hex = (normal + "%s" + reset) % (i, color)
newline = '\n' if i % 6 == 3 else ''
print index, hex, newline, 发布于 2016-09-06 12:04:39
虽然并不完全是一种“测试模式”,但我有色选择器:

发布于 2016-09-22 20:50:45
我编写的另一个脚本位于VTE存储库中:https://git.gnome.org/browse/vte/plain/perf/256test.sh?h=vte-0-38。
它需要一个120或更多列的窗口,但是6x6x6立方体的颜色排列得很好和紧凑。索引的第一个数字为了紧凑而被去掉,您可以很容易地计算出它们。垂直条形图为您提供了检查前景颜色的准确RGB的能力,而不需要反混叠(就像在数字上那样)。
输出的顶部(未在下面的屏幕截图中显示)演示了大胆与明亮的歧义之间的疯狂,即大胆的转义序列与遗留的8种颜色的前景转义序列之一相结合,也会切换到明亮的对应颜色,而对于新样式(具有256种颜色能力的)转义序列,则不再是这种情况,即使是前8种颜色也不一样。至少这就是xterm和VTE (GNOME终端等)的方式。规矩点。
这个屏幕截图显示了大约一半的输出:

https://askubuntu.com/questions/821157
复制相似问题