Check linux/unix terminal color
2 min readFeb 29, 2024
check_color.sh
awk 'BEGIN{
s="/\\/\\/\\/\\/\\"; s=s s s s s s s s;
for (colnum = 0; colnum<77; colnum++) {
r = 255-(colnum*255/76);
g = (colnum*510/76);
b = (colnum*255/76);
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+1,1);
}
printf "\n";
}'
If your terminal support true color (24 bits color), you can see this (Mac iTerm)
if it does not work, you may see something like this (mac default terminal):
How to get true color on Mac?
Install iTerm will work.
How to have true color on linux?
In the linux server, the issue have a good change caused by the screen or tmux.
For screen, looks need to use a higher version (have not check this yet).
For Tmux, add the following to the config file:
~/.tmux.conf
can solve the problem [2]
set -g default-terminal "xterm-256color"
# make colors inside tmux look the same as outside of tmux
# see https://github.com/tmux/tmux/issues/696
# see https://stackoverflow.com/a/41786092
set-option -ga terminal-overrides ",xterm-256color:Tc"