Skip to main content
Include revision (commit hash) to ensure users are executing the expected code
Source Link

256-colour test pattern

To get the below image, use:

curl -s https://gist.githubusercontent.com/HaleTom/89ffe32783f89f403bba96bd7bcd1263/raw/e50a28ec54188d2413518788de6c6367ffcea4f7/print256colours.sh | bash

256-colour test pattern

The gist bash/zsh code is shellcheck clean, and also supports "Look Ma, no subprocesses!".


Alternatively, for a bash quicky:

for i in {0..255} ; do
    printf "\x1b[48;5;%sm%3d\e[0m " "$i" "$i"
    if (( i == 15 )) || (( i > 15 )) && (( (i-15) % 6 == 0 )); then
        printf "\n";
    fi
done

For total overkill, the granddaddy of the lot is terminal-colors, a 572-line script with multiple output formats.

You can also print a true color (24-bit) test pattern.

256-colour test pattern

To get the below image, use:

curl -s https://gist.githubusercontent.com/HaleTom/89ffe32783f89f403bba96bd7bcd1263/raw/ | bash

256-colour test pattern

The gist bash/zsh code is shellcheck clean, and also supports "Look Ma, no subprocesses!".


Alternatively, for a bash quicky:

for i in {0..255} ; do
    printf "\x1b[48;5;%sm%3d\e[0m " "$i" "$i"
    if (( i == 15 )) || (( i > 15 )) && (( (i-15) % 6 == 0 )); then
        printf "\n";
    fi
done

For total overkill, the granddaddy of the lot is terminal-colors, a 572-line script with multiple output formats.

You can also print a true color (24-bit) test pattern.

256-colour test pattern

To get the below image, use:

curl -s https://gist.githubusercontent.com/HaleTom/89ffe32783f89f403bba96bd7bcd1263/raw/e50a28ec54188d2413518788de6c6367ffcea4f7/print256colours.sh | bash

256-colour test pattern

The gist bash/zsh code is shellcheck clean, and also supports "Look Ma, no subprocesses!".


Alternatively, for a bash quicky:

for i in {0..255} ; do
    printf "\x1b[48;5;%sm%3d\e[0m " "$i" "$i"
    if (( i == 15 )) || (( i > 15 )) && (( (i-15) % 6 == 0 )); then
        printf "\n";
    fi
done

For total overkill, the granddaddy of the lot is terminal-colors, a 572-line script with multiple output formats.

You can also print a true color (24-bit) test pattern.

Commonmark migration
Source Link

256-colour test pattern

To get the below image, use:

curl -s https://gist.githubusercontent.com/HaleTom/89ffe32783f89f403bba96bd7bcd1263/raw/ | bash

[![256-colour test pattern][1]][1]256-colour test pattern

The gist bash/zsh code is shellcheck clean, and also supports "Look Ma, no subprocesses!".


Alternatively, for a bash quicky:

for i in {0..255} ; do
    printf "\x1b[48;5;%sm%3d\e[0m " "$i" "$i"
    if (( i == 15 )) || (( i > 15 )) && (( (i-15) % 6 == 0 )); then
        printf "\n";
    fi
done

For total overkill, the granddaddy of the lot is terminal-colors, a 572-line script with multiple output formats.

You can also print a true color (24-bit) test pattern. [1]: https://i.sstatic.net/L6yhm.png

256-colour test pattern

To get the below image, use:

curl -s https://gist.githubusercontent.com/HaleTom/89ffe32783f89f403bba96bd7bcd1263/raw/ | bash

[![256-colour test pattern][1]][1]

The gist bash/zsh code is shellcheck clean, and also supports "Look Ma, no subprocesses!".


Alternatively, for a bash quicky:

for i in {0..255} ; do
    printf "\x1b[48;5;%sm%3d\e[0m " "$i" "$i"
    if (( i == 15 )) || (( i > 15 )) && (( (i-15) % 6 == 0 )); then
        printf "\n";
    fi
done

For total overkill, the granddaddy of the lot is terminal-colors, a 572-line script with multiple output formats.

You can also print a true color (24-bit) test pattern. [1]: https://i.sstatic.net/L6yhm.png

256-colour test pattern

To get the below image, use:

curl -s https://gist.githubusercontent.com/HaleTom/89ffe32783f89f403bba96bd7bcd1263/raw/ | bash

256-colour test pattern

The gist bash/zsh code is shellcheck clean, and also supports "Look Ma, no subprocesses!".


Alternatively, for a bash quicky:

for i in {0..255} ; do
    printf "\x1b[48;5;%sm%3d\e[0m " "$i" "$i"
    if (( i == 15 )) || (( i > 15 )) && (( (i-15) % 6 == 0 )); then
        printf "\n";
    fi
done

For total overkill, the granddaddy of the lot is terminal-colors, a 572-line script with multiple output formats.

You can also print a true color (24-bit) test pattern.

Add curl to run automatically
Source Link
Tom Hale
  • 3.5k
  • 5
  • 17
  • 35

256-colour test pattern

256-colour test pattern To get the below image, use:

curl -s https://gist.githubusercontent.com/HaleTom/89ffe32783f89f403bba96bd7bcd1263/raw/ | bash

[![256-colour test pattern][1]][1]

For the above, you can use myThe gist bash/zsh code which is shellcheckshellcheck clean, and also supports "Look Ma, no subprocesses!".

 

OrAlternatively, for a bashbash quicky:

for i in {0..255} ; do
    printf "\x1b[48;5;%sm%3d\e[0m " "$i" "$i"
    if (( i == 15 )) || (( i > 15 )) && (( (i-15) % 6 == 0 )); then
        printf "\n";
    fi
done

For total overkill, the granddaddy of the lot is terminal-colors, a 572-line script with multiple output formats.

You can also print a true color (24-bit) test pattern. [1]: https://i.sstatic.net/L6yhm.png

256-colour test pattern

[![256-colour test pattern][1]][1]

For the above, you can use my gist bash/zsh code which is shellcheck clean, and also supports "Look Ma, no subprocesses!"

Or for a bash quicky:

for i in {0..255} ; do
    printf "\x1b[48;5;%sm%3d\e[0m " "$i" "$i"
    if (( i == 15 )) || (( i > 15 )) && (( (i-15) % 6 == 0 )); then
        printf "\n";
    fi
done

For total overkill, the granddaddy of the lot is terminal-colors, a 572-line script with multiple output formats.

You can also print a true color (24-bit) test pattern. [1]: https://i.sstatic.net/L6yhm.png

256-colour test pattern

To get the below image, use:

curl -s https://gist.githubusercontent.com/HaleTom/89ffe32783f89f403bba96bd7bcd1263/raw/ | bash

[![256-colour test pattern][1]][1]

The gist bash/zsh code is shellcheck clean, and also supports "Look Ma, no subprocesses!".

 

Alternatively, for a bash quicky:

for i in {0..255} ; do
    printf "\x1b[48;5;%sm%3d\e[0m " "$i" "$i"
    if (( i == 15 )) || (( i > 15 )) && (( (i-15) % 6 == 0 )); then
        printf "\n";
    fi
done

For total overkill, the granddaddy of the lot is terminal-colors, a 572-line script with multiple output formats.

You can also print a true color (24-bit) test pattern. [1]: https://i.sstatic.net/L6yhm.png

Add link to true color (24-bit) test pattern
Source Link
Tom Hale
  • 3.5k
  • 5
  • 17
  • 35
Loading
Add link to terminal-colors
Source Link
Tom Hale
  • 3.5k
  • 5
  • 17
  • 35
Loading
Update picture to gist code, change quicky to print colour in background.
Source Link
Tom Hale
  • 3.5k
  • 5
  • 17
  • 35
Loading
change quicky echo to printf, clean it up
Source Link
Tom Hale
  • 3.5k
  • 5
  • 17
  • 35
Loading
Added coloured blocks, shellcheck clean, no subprocesses
Source Link
Tom Hale
  • 3.5k
  • 5
  • 17
  • 35
Loading
Mention code is in bash
Source Link
Tom Hale
  • 3.5k
  • 5
  • 17
  • 35
Loading
Show screenshot in post
Source Link
edwinksl
  • 23.9k
  • 16
  • 75
  • 101
Loading
Source Link
Tom Hale
  • 3.5k
  • 5
  • 17
  • 35
Loading