Skip to content

Instantly share code, notes, and snippets.

@linrock
Last active September 29, 2015 23:58
Show Gist options
  • Save linrock/1689620 to your computer and use it in GitHub Desktop.
Save linrock/1689620 to your computer and use it in GitHub Desktop.
Print out 256-color terminal color codes in their respective colors
#!/bin/bash
for i in {0..15}; do
row=
for j in {1..16}; do
color=$(( $i*16 + $j -1 ))
code="\033[00;38;5;${color}m${color}"
if [[ $row == "" ]]; then
row=$code
elif [[ $color -lt 11 ]]; then
row="$row\x20\x20\x20$code"
elif [[ $color -lt 101 ]]; then
row="$row\x20\x20$code"
else
row="$row $code"
fi
done
echo -e $row
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment