Last active
May 27, 2018 17:02
-
-
Save pacohope/e6099951e8251d6c1325a425180e40a8 to your computer and use it in GitHub Desktop.
Print out all the possible ANSI terminal colours in a nice table.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
# | |
# I hate doing this. This is someone else's code. For a long time I didn't know who to credit. Now | |
# I do: https://stackoverflow.com/questions/27159322/rgb-values-of-the-colors-in-the-ansi-extended-colors-index-17-255 | |
# It is by a user named adaephon (https://stackoverflow.com/users/2992551/adaephon) | |
# | |
function termcolors () | |
{ | |
print TERM | |
print -P "Foreground: >█<" | |
print -P "Background: >%S█%s<\n" | |
print " 0 1 2 3 4 5 6 7" | |
for b (0 1) | |
do | |
printf "%d %2d " $b $(( 8 * b )) | |
for r (0 1 2 3 4 5 6 7) | |
do | |
c=$(( 8 * b + r )) | |
print -nP "%K{$c} %k" | |
done | |
printf " %2d\n" $(( 8 * b + 7 )) | |
done | |
print RGB | |
for r (0 1 2 3 4 5) | |
do | |
print "$r $(( 16 + 36 * r )) - $(( 16 + 36 * r + 35 ))\n 0 1 2 3 4 5" | |
for g (0 1 2 3 4 5) | |
do | |
printf "%d %3d " $g $(( 16 + 36 * r + 6 * g )) | |
for b (0 1 2 3 4 5) | |
do | |
c=$(( 16 + 36 * r + 6 * g + b )) | |
print -nP "%K{$c} %k" | |
done | |
printf " %3d\n" $(( 16 + 36 * r + 6 * g + 5)) | |
done | |
done | |
print GRAY | |
for g in $(seq 0 23) | |
do | |
c=$(( 232 + g )) | |
printf "%2d %3d " $g $c | |
print -P "%K{$c} %k" | |
done | |
} | |
termcolors |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment