Related, one of my favorite in-depth stack overflow answers: https://stackoverflow.com/a/33206814
for i in {0..255}; do printf "\x1b[38;5;${i}mcolor%-5i\x1b[0m" $i ; if ! (( ($i + 1 ) % 8 )); then echo ; fi ; doneAnd you know that. Why are you arguing about this?
for i in {0..255}; do printf '\e[48;5;%dm%-10s' "$i" "color$i"; if (( (i >= 16 && i < 232) ? (i%6 == 3) : (i%8 == 7) )); then printf '\e[m\n'; fi; done
There are several more-complete versions floating around on the internet; I have personalized 2 myself ... hmm, I don't seem to have the one I remember that does contrast automatically ...