11

How do I print a 256-colour test pattern in my terminal?

I want to check that my terminal correctly supports 256 colours.

4
  • 6
    Please do not crosspost (askubuntu.com/questions/821157/…).
    – edwinksl
    Sep 6, 2016 at 7:00
  • 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?
    – Tom Hale
    Sep 6, 2016 at 7:17
  • 3
    non Ubuntu related question should redirected here
    – Emmanuel
    Sep 6, 2016 at 10:26
  • Yes - this is not limited to Ubuntu
    – Tom Hale
    Sep 6, 2016 at 10:35

2 Answers 2

21

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 :)

9
  • Not sure why you formatted it this way but at least it works and looks good. Sep 6, 2016 at 6:42
  • 1
    Suggestions for improvement?
    – Tom Hale
    Sep 6, 2016 at 6:58
  • Works also on zsh
    – Emmanuel
    Sep 6, 2016 at 9:32
  • 1
    can try that one printf "%03d\e[48;5;${i}m \e[0m " $i;
    – Emmanuel
    Sep 6, 2016 at 9:55
  • On bash, printf is not a builtin -- so this does indeed use subprocesses
    – Zach R
    Mar 30, 2020 at 23:01
8

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.
2
  • 3
    “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.
    – phg
    Sep 6, 2016 at 7:47
  • 1
    Said application is available for ubuntu. For more info, refer this link vim.org/scripts/script.php?script_id=1349
    – SHW
    Sep 6, 2016 at 7:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.