just use Bash functions, like, say this one:
make()
{
pathpat="(/[^/]*)+:[0-9]+"
ccred=$(echo -e "\033[0;31m")
ccyellow=$(echo -e "\033[0;33m")
ccend=$(echo -e "\033[0m")
/usr/bin/make "$@" 2>&1 | sed -E -e "/[Ee]rror[: ]/ s%$pathpat%$ccred&$ccend%g" -e "/[Ww]arning[: ]/ s%$pathpat%$ccyellow&$ccend%g"
return ${PIPESTATUS[0]}
}
How to turn on or off colors in bash
by NIX CRAFT on NOVEMBER 4, 2006 · 1 COMMENT· LAST UPDATED NOVEMBER 4, 2006
in BASH SHELL
Q. How do I turn on or off file name colors in bash shell?
A. Most modern Linux distro comes with alias that defines colors for your file. However ls command is responsible for displaying color on screen for files, directories and other object.
By default, color is not used to distinguish types of files. You need to pass --color option to ls command.
Task: Turn off colors
Type the following command
$ ls --color=none
Or just remove alias with unalias command:
$ unalias ls
Task: Turn on colors
Use any of the following command:
$ ls --color=auto
$ ls --color=tty
You can add or remove ls alias from ~/.bash_profile or ~/.bashrc file.
this commands for bash that are working well
handy tput commands
tput bold - Bold effect
tput rev - Display inverse colors
tput sgr0 - Reset everything
tput setaf {CODE}- Set foreground color, see color {CODE} below
tput setab {CODE}- Set background color, see color {CODE} below
Colors {code} code for tput command
Color {code} Color
0 Black
1 Red
2 Green
3 Yellow
4 Blue
5 Magenta
6 Cyan
7 White
greprather thanlsgrepdoesn't output color-coded results when I use it in a shell script.tputand I also referred in my answerls --color=autobut not as accurate as what John1024 said...have a nice day :)