3 ms·
Related, one of my favorite in-depth stack overflow answers: https://stackoverflow.com/a/33206814 https://stackoverflow.com/a/33206814
by turminal 3y ago
Related, one of my favorite in-depth stack overflow answers: https://stackoverflow.com/a/33206814 https://stackoverflow.com/a/33206814
- chatmasta 3y agoHere's a useful one-liner to print the code for each of the 256 colors in their respective color, so that you can quickly see which one you want: for i in {0..255}; do printf "\x1b[38;5;${i}mcolor%-5i\x1b[0m" $i ; if ! (( ($i + 1 ) % 8 )); then echo ; fi ; done
- WalterBright 3y agoYou can make any program in a ; language a one liner.
- olddustytrail 3y agoWell sure, but I think everyone would understand a one liner as something that fits in a single loop. And you know that. Why are you arguing about this?
- deleted 3y ago[deleted]
- o11c 3y agoIf 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 ...