For example, I\'d like to color the output of the locate command so it\'s easily distinguished from the other terminal text.
It should work something li
Use the tput command.
Most terminals support 8 foreground text colors and 8 background colors (though some support as many as 256). Using the setaf and setab capabilities, we can set the foreground and background colors. The exact rendering of colors is a little hard to predict. Many desktop managers impose "system colors" on terminal windows, thereby modifying foreground and background colors from the standard. Despite this, here are what the colors should be:
Value Color
0 Black
1 Red
2 Green
3 Yellow
4 Blue
5 Magenta
6 Cyan
7 White
8 Not used
9 Reset to default color
Actual example: set color to red, cat and then change color back:
tput setaf 1; cat /proc/meminfo ; tput setaf 9