shell

Make colored output

I found a nice script in stackoverflow about how to color the output of make in bash. It works by filtering the output and looking for certain expressions to highlight.

Placing this function definition in your .bashrc file defines a bash make function which gets executed instead of the command. This way we can shadow the real make command and create our own custom version.

make()
{
   ccred=$(echo -e "33[1;31m")
   ccyellow=$(echo -e "33[1;33m")
   ccend=$(echo -e "33[0m")
   /usr/bin/make "$@" 2>&1 | sed -e "s/[Ee]rror:/$ccred&$ccend/g" -e "s/[Ww]arning:/$ccyellow&$ccend/g"
   return ${PIPESTATUS[0]}
}

Of course, you can use this technique to wrap other commands as well.

Enjoy!

speak up

Add your comment below, or trackback from your own site.

Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*Required Fields