There is a much better way to achieve custom coloring:
colorit
You can use it, as shown in other answers, via some_command | colorit some_command | colorit , but it is highly configurable over .coloritrc . I have things like
dnl Define some useful color variables define(`red', `1') define(`green', `2') define(`magenta', `5') dnl dnl Mark macro arguments: regexp foreground-color [background-color] dnl define(`mark', ``mark "$1"'' `ifelse(`$#', `3', ``"\033[3$2;4$3m"'', ``"\033[3$2m"'')' `"\033[m"') dnl divert mark(`warning', magenta) mark(`Warning', magenta) mark(`Traceback', magenta) mark(`Error', red) mark(`FAIL', red) mark(`ERROR', red) mark(`XFAIL', green) mark(`ok', green) mark(`OK', green) mark(`PASS', green)
and use it all the time for coloring the output of the compiler and similar materials. See .coloritrc for more details.
source share