Highlighting Text Output
tput command can be used to format text output in a variety of ways. Here is a small example:
Your output may vary from the above depending on your terminal settings.
Here is the script for the above example:
This follows a two-step process. First
setaf sets the foreground (the text) to the desired color. Then
smso reverses everything (foreground and background) - so the background becomes the selected color, and the text takes on the color of the normal background.
Useful for when you want something to really catch the user’s eye. Use sparingly.
There’s far more to
tput than I have shown here. I had no idea, just from reading the manpage. Try this for more info.
Or how about this question and its amazing answers, regarding color values.
setaf <value> - set ANSI foreground
setab <value> - set ANSI background
smso - start “standout” mode (reverses things, or bolds them - depends on the terminal)
sgr0 - return to normal output
This script shows the basic set of colors most terminals should be able to use:
Here is what I get:
The chances are good that your terminal can show millions of colors, not eight. But I only need the occasional touch, so these are fine for me.