Colorful make output

This handy piece of code colors errors and warnings in make output.
(put it in your .bash_profile)

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]}
}

via shawnwilsher.com

An alternative would be to install colormake and use that instead of the normal make command.

About Florian Beer

I am running my own company 42dev where I provide web application development & hosting services for my clients.

Leave a Reply

Your email address will not be published. Required fields are marked *

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