Print a 256-color test pattern in the terminal
12,053
Solution 1
256-colour test pattern
For the above, you can use my bash code. ("Look Ma, no subprocesses!")
Or for a bash quicky:
for i in {0..255} ; do
printf "\x1b[38;5;${i}m%3d " "${i}"
if (( $i == 15 )) || (( $i > 15 )) && (( ($i-15) % 12 == 0 )); then
echo;
fi
done
24-bit / truecolour test pattern
See this question for the full spectrum :)
Solution 2
Install an application named colortest
and use the following commands to test the ASCII color graph
colortest-8 => Display color palette using 8 colors.
colortest-16 => Display color palette using 16 colors.
colortest-256 => Display color palette using 256 colors.
Related videos on Youtube
Author by
Tom Hale
Updated on September 18, 2022Comments
-
Tom Hale over 1 year
How do I print a 256-colour test pattern in my terminal?
I want to check that my terminal correctly supports 256 colours.
-
lblasa over 7 yearsPlease do not crosspost (askubuntu.com/questions/821157/…).
-
Tom Hale over 7 yearsMy understanding is that that is to prevent time being wasted answering a question already answered. It's entirely relevant to both sites... How to say which is more relevant?
-
Emmanuel over 7 yearsnon Ubuntu related question should redirected here
-
Tom Hale over 7 yearsYes - this is not limited to Ubuntu
-
-
Julie Pelletier over 7 yearsNot sure why you formatted it this way but at least it works and looks good.
-
Tom Hale over 7 yearsSuggestions for improvement?
-
phg over 7 years“Install an application named colortest”—this kind of begs the question. Where does that
colortest
package originate? It doesn’t appear to be in the Fedora or Arch repos. -
SHW over 7 yearsSaid application is available for
ubuntu
. For more info, refer this link vim.org/scripts/script.php?script_id=1349 -
Emmanuel over 7 yearscan try that one
printf "%03d\e[48;5;${i}m \e[0m " $i;
-
Tom Hale about 4 years@Zach R I just did a quick google... What evidence do you have for you assertion it's not a built-in?
-
Zach R about 4 years``` $ bash -c 'which printf' /usr/bin/printf $ zsh -c 'which printf' printf: shell built-in command ```
-
Zach R about 4 yearsApparently it is a builtin, per the Bash documentation. Bash just doesn't show builtins with "which". manpages.ubuntu.com/manpages/xenial/man7/bash-builtins.7.html