Tom*_*ale 25 colors terminal-emulator terminal
如何测试我的终端 / tmux 是否正确设置为显示真彩色 / 24 位颜色 / 1680 万色?
Tom*_*ale 50
以下脚本将生成一个测试模式,如:
您可以选择将其称为:
width=1000 truecolor-test
Run Code Online (Sandbox Code Playgroud)
它将打印一个width列模式。
#!/bin/bash
# Based on: https://gist.github.com/XVilka/8346728
awk -v term_cols="${width:-$(tput cols || echo 80)}" 'BEGIN{
s="/\\";
for (colnum = 0; colnum<term_cols; colnum++) {
r = 255-(colnum*255/term_cols);
g = (colnum*510/term_cols);
b = (colnum*255/term_cols);
if (g>255) g = 510-g;
printf "\033[48;2;%d;%d;%dm", r,g,b;
printf "\033[38;2;%d;%d;%dm", 255-r,255-g,255-b;
printf "%s\033[0m", substr(s,colnum%2+1,1);
}
printf "\n";
}'
Run Code Online (Sandbox Code Playgroud)
小智 12
我编辑了Tom Hale 的答案中的函数,添加了行数选项,从而分割了输出。我发现它很有用,因为它显示了更详细的颜色。
#!/bin/bash
# Based on: https://gist.github.com/XVilka/8346728 and https://unix.stackexchange.com/a/404415/395213
awk -v term_cols="${width:-$(tput cols || echo 80)}" -v term_lines="${height:-1}" 'BEGIN{
s="/\\";
total_cols=term_cols*term_lines;
for (colnum = 0; colnum<total_cols; colnum++) {
r = 255-(colnum*255/total_cols);
g = (colnum*510/total_cols);
b = (colnum*255/total_cols);
if (g>255) g = 510-g;
printf "\033[48;2;%d;%d;%dm", r,g,b;
printf "\033[38;2;%d;%d;%dm", 255-r,255-g,255-b;
printf "%s\033[0m", substr(s,colnum%2+1,1);
if (colnum%term_cols==term_cols) printf "\n";
}
printf "\n";
}'
Run Code Online (Sandbox Code Playgroud)