dotfiles/bin/colortest

50 lines
959 B
Text
Raw Normal View History

2023-06-20 11:10:34 -07:00
#!/usr/bin/env zsh
2023-08-22 09:45:24 -07:00
function print_color
{
#local formatted=`printf "%4d " $1`
local formatted=" "
print -Pn "%K{$1}${formatted}%k"
}
2023-06-20 11:10:34 -07:00
2023-08-22 09:45:24 -07:00
print -n ' '
for (( i = 0; i < 8; i += 1 )); do
printf "%4d " $i
done
print
2023-06-20 11:10:34 -07:00
print -n 'Normal: '
2023-08-22 09:45:24 -07:00
for (( i = 0; i < 8; i += 1 )); do
print_color $i
2023-06-20 11:10:34 -07:00
done
print
2023-08-22 09:45:24 -07:00
print -n ' '
for (( i = 8; i < 16; i += 1 )); do
printf "%4d " $i
done
print
2023-06-20 11:10:34 -07:00
print -n 'Bright: '
2023-08-22 09:45:24 -07:00
for (( i = 8; i < 16; i += 1 )); do
print_color $i
2023-06-20 11:10:34 -07:00
done
print
SUPPORTED_COLORS=`echotc Co`
COLORS_PER_LINE=16
print
print "Color Table ($SUPPORTED_COLORS supported colors)"
for (( base = 0; base < $SUPPORTED_COLORS ; base += $COLORS_PER_LINE )); do
for (( i = base; i < base + $COLORS_PER_LINE && i < $SUPPORTED_COLORS; i += 1 )); do
2023-08-22 09:45:24 -07:00
printf "%4d " $i
done
print
for (( i = base; i < base + $COLORS_PER_LINE && i < $SUPPORTED_COLORS; i += 1 )); do
print_color $i
2023-06-20 11:10:34 -07:00
done
print
done