You are not logged in.
Pages: 1
A bash script for displaying the available 256 term colours. I'm working on a script which requires coloured output, and different terms display colours differently, so I need the colours for a reference. This is not the first, and won't be the last such script, but I wanted something that displayed the colours in a coherent manner. I saw the same output done using ruby and thought it was good. I decided to write something short and simple in bash, mostly as an exercise.
#!/bin/bash
#
for i in $(seq -f %03g 0 255)
do
j=$(echo $i | sed 's/^0*//')
printf "\e[48;5;${i}m\e[38;5;15m ${i} "
printf "\e[48;5;0m\e[38;5;${i}m ${i} "
case "$i" in
"007") printf "\n" ;;
"015") printf "\n" ;;
esac
if [[ $j -ge 21 && $(( (${j}-15) % 6 )) -eq 0 ]]
then
printf "\n"
fi
done
I hope it's useful.
Offline
Very nice -- thank you!
Para todos todo, para nosotros nada
Offline
I hope it's useful.
Yes indeed, and appreciated, thanks.
Offline
Pages: 1