
Untitled
By: a guest on
May 30th, 2012 | syntax:
None | size: 0.53 KB | hits: 13 | expires: Never
#!/bin/bash
# Based on http://www.commandlinefu.com/commands/view/5879/show-numerical-values-for-each-of-the-256-colors-in-bash.
# See also http://www.pixelbeat.org/docs/terminal_colours/#256.
colors() {
i=$1
while [ $i -le $2 ]; do
printf "\e[48;05;${i}m"
test "$codes" = "-n" && printf "%3d " $i || printf " "
printf "\e[0m"
test $(((i + 1 - $1) % $3)) -eq "0" && echo
i=$((i + 1))
done
echo
}
codes="$1"
colors 0 15 8
colors 16 231 36
colors 232 255 100