Skip navigation

Curtis just gave me this incredibly handy piece of code that higlights errors and warnings in make output. Now, when I’m building, all the warnings are highlighted in yellow, and the errors in red. Just put the following in your bash profile script:

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

Of course, improvements and more ideas welcome! Thanks goes to Curtis for this!

9 Comments

  1. Absolutely delicious. Thank you!

    • Hanspeter
    • Posted December 3, 2008 at 18:29 (6:29 pm)
    • Permalink

    Looks nice, but wordpress seems to have messed many of the quote characters.

  2. @Hanspeter
    I think if you drag and copy, you should be good. I don’t see any escape issues – just some layout truncation issues.

    • Daniel Holbert
    • Posted December 3, 2008 at 19:06 (7:06 pm)
    • Permalink

    On Linux, you can just install the ‘colormake’ package and use that in place of make.

    (colormake should work on non-Linux platforms, too — you’d just need to download the perl & bash scripts and put them in the right places yourself)

    More info:
    http://bre.klaki.net/programs/colormake/

    • Hanspeter
    • Posted December 3, 2008 at 21:02 (9:02 pm)
    • Permalink

    Nope. It’s giving me curly quotes for the terminating quote on the first line, the opening quote on the 2nd line, and the ones around warning in the 2nd to last line. If you look at the source code of this page, wordpress is converting the quote characters into & # 8221; and & # 8220; (hopefully I spaced that out enough that it won’t convert them into the actual characters here…)

    (on windows, but obviously the wordpress output is system agnostic)

    • Mike Beltzner
    • Posted December 4, 2008 at 03:07 (3:07 am)
    • Permalink

    Any way we can get this styling applied to the buildlogs submitted to tinderbox so that it’s easier to spot the problems when investigating a failed build?

  3. @Mike
    I honestly don’t know.

    • adw
    • Posted February 10, 2009 at 20:21 (8:21 pm)
    • Permalink

    \o/

  4. for sed, -E appears to be an OSX only flag. I think the linux equivalent is -r, so:

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

One Trackback/Pingback

  1. By blog.no-panic.at » Colorful make output on 04 Dec 2008 at 3:30 am

    […] via shawnwilsher.com […]

Comments are closed.