Print a 256-color test pattern in the terminal

12,053

Solution 1

256-colour test pattern

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.
Share:
12,053

Related videos on Youtube

Tom Hale
Author by

Tom Hale

Updated on September 18, 2022

Comments

  • Tom Hale
    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
      lblasa over 7 years
      Please do not crosspost (askubuntu.com/questions/821157/…).
    • Tom Hale
      Tom Hale over 7 years
      My 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
      Emmanuel over 7 years
      non Ubuntu related question should redirected here
    • Tom Hale
      Tom Hale over 7 years
      Yes - this is not limited to Ubuntu
  • Julie Pelletier
    Julie Pelletier over 7 years
    Not sure why you formatted it this way but at least it works and looks good.
  • Tom Hale
    Tom Hale over 7 years
    Suggestions for improvement?
  • phg
    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
    SHW over 7 years
    Said application is available for ubuntu. For more info, refer this link vim.org/scripts/script.php?script_id=1349
  • Emmanuel
    Emmanuel over 7 years
    can try that one printf "%03d\e[48;5;${i}m \e[0m " $i;
  • Tom Hale
    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
    Zach R about 4 years
    ``` $ bash -c 'which printf' /usr/bin/printf $ zsh -c 'which printf' printf: shell built-in command ```
  • Zach R
    Zach R about 4 years
    Apparently 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.htm‌​l