Gcc

From Attie's Wiki
Jump to: navigation, search

Highlight the output of gcc

  • warnings will be highlighted yellow
  • errors will be highlighted red
stdbuf -oL make 2>&1 | \
  sed -re 's/^([^:]+:[0-9]+:[0-9]+: warning: .+)$/\x1B[93m&\x1B[m/g' \
       -e 's/^([^:]+:[0-9]+:[0-9]+: error: .+)$/\x1B[91m&\x1B[m/g'

script form

Or, put this in your path, called mk or something:

#!/bin/bash
set -o pipefail
stdbuf -oL make "$@" 2>&1 | \
  sed -ure 's/^[^:]+:[0-9]+:[0-9]+: warning: .+$/\x1B[38;5;208m&\x1B[m/g' \
        -e 's/^[^:]+:[0-9]+:[0-9]+: (fatal )?error: .+$/\x1B[38;5;161m&\x1B[m/g' \
        -e 's/^.+: undefined reference to .+$/\x1B[38;5;161m&\x1B[m/g' \
        -e 's/^[^:]+:[0-9]+:[0-9]+: note: .+$/\x1B[38;5;94m&\x1B[m/g' \
        -e 's/^[^:]+: In function .+$/\x1B[38;5;34m&\x1B[m/g' \
        -e 's/^(\x1B\[38;5;208m.*)(TODO)(.*)$/\1\x1B[38;5;33m\2\x1B[38;5;208m\3/g' \
        -e 's/^(make(\[[0-9]*\])?: (Entering|Leaving) directory )(`.*)$/\x1B[38;5;90m\1\x1B[38;5;200m\4\x1B[m/g' \
        -e 's/^[^\x1B].+$/\x1B[90m&\x1B[m/g'
exit $?
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox