How to print out all available terminal colors. And other useful Linux tricks.

Posted: November 7, 2017. At: 11:28 AM. This was 2 weeks ago. Post ID: 11515
Page permalink: http://securitronlinux.com/debian-testing/how-to-print-out-all-available-terminal-colors-and-other-useful-linux-tricks/

This one-liner will print out all available terminal colors for your chosen Linux terminal application. This is very useful for creating a colorful bash prompt and the user wishes to know which color codes will work and look good in the terminal.

for x in {0..8}; do for i in {30..37}; do for a in {40..47}; do echo -ne "\e[$x;$i;$a""m\\\e[$x;$i;$a""m\e[0;37;40m "; done; echo; done; done; echo ""

Also, there is the colortest package for Ubuntu and Linux Mint/Debian.

This will print colors to the terminal. Install the package.

sudo apt install colortest

Then run it to see the available colors.

[email protected]:~$ colortest-16b

This will print all of the color codes for 16 color display.

There is also a command that will print all colors for a 256 color range.

[email protected]:~$ colortest-256

These commands will really help creating a bash script with colored output, and it is desirable to see what the colors look like before using them in your script.

No comments have been made. Use this form to start the conversation :)

Leave a Reply