Last active
September 29, 2015 23:58
-
-
Save linrock/1689620 to your computer and use it in GitHub Desktop.
Print out 256-color terminal color codes in their respective colors
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/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