Skip to content

Instantly share code, notes, and snippets.

@pborenstein
Created August 10, 2014 03:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pborenstein/a9d14365f3b715a10acc to your computer and use it in GitHub Desktop.
Save pborenstein/a9d14365f3b715a10acc to your computer and use it in GitHub Desktop.
Print all the xterm colors
#! /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