问题描述
如何在终端中打印256色测试图案?
我想检查我的终端是否正确支持256种颜色。
最佳解决方案
256色测试图案
要获得以下图像,请使用:
curl -s https://gist.githubusercontent.com/HaleTom/89ffe32783f89f403bba96bd7bcd1263/raw/ | bash
要点bash /zsh代码是shellcheck清洁,并且还支持“Look Ma,没有子进程!”。
或者,对于bash quicky:
for i in {0..255} ; do
printf "\x1b[48;5;%sm%3d\e[0m " "$i" "$i"
if (( i == 15 )) || (( i > 15 )) && (( (i-15) % 6 == 0 )); then
printf "\n";
fi
done
对于总矫枉过正,该批次的祖父是terminal-colors,一个带有多个output formats的572-line script。
次佳解决方案
我找到了由Justin Abrahms编写的nice Python script for that on GitHub&#