Created
August 10, 2014 03:49
-
-
Save pborenstein/a9d14365f3b715a10acc to your computer and use it in GitHub Desktop.
Print all the xterm colors
This file contains hidden or 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
#! /usr/bin/env bash | |
# print all the xterm colors | |
# see http://serverfault.com/a/91873 about caculating the rgb values | |
for c in {0..15} | |
do | |
printf "\033[38;5;%dm %2d" $c $c | |
if (( (c+1) % 8 == 0 )) ; then | |
echo | |
fi | |
done | |
for r in {0..5} | |
do | |
for g in {0..5} | |
do | |
for b in {0..5} | |
do | |
(( rgb = (36 * $r) + (6 * $g) + $b + 16)) | |
(( nrgb = rgb - 16 )) | |
printf "\033[38;5;%dm (%3d) %d %d %d" $rgb $rgb $r $g $b | |
if (( (nrgb+1) % 6 == 0 )) ; then | |
echo | |
fi | |
if (( g == 5 && b == 5 )) ; then | |
echo | |
fi | |
done | |
done | |
done | |
for c in {232..255} | |
do | |
printf "\033[38;5;%dm %2d" $c $c | |
if (( (c+1) % 8 == 0 )) ; then | |
echo | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment