How to work with text colors on Linux

$ echo -e $GREEN I $YELLOW love $BLUE color $NORMAL
I love color

The -e option with the echo command is described in the man page as “enable interpretation of backslash escapes” but it also allows these color options to work.

How much the letters stand out will, of course, depend on the background color in your window, but you should see the colors selected. The NORMAL setting returns the font color to the default so that you don’t end up displaying all of your text in the last color used.

To avoid having two blank characters in between the words in your phrase, use a command like this instead:

$ echo -e $GREEN I$YELLOW love$BLUE color$NORMAL
I love color

If you want additional colors, you could add these to your Colors file:

LTGREEN="33[32m"
LTYELLOW="33[33m"
LTBLUE="33[34m"
LTMAGENTA="33[35m"
LTCYAN="33[36m"
LTWHITE="33[37m"

NOTE: If ever you mess up and your text colors don’t go back to normal, issue the command below to fix the problem.

$ echo -e $NORMAL

Background colors

You can also use color settings to change the background color of your screen. The command shown below would change your background color after the command is issued, leaving the space above it with the prior background color.



Source link

Leave a Comment