If we're doing one-liners, there are several advantages to:
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 ...