Skip to content

Instantly share code, notes, and snippets.

@staslev
Forked from wadouk/bashrc.sh
Last active January 3, 2016 00:29
Show Gist options
  • Save staslev/8383022 to your computer and use it in GitHub Desktop.
Save staslev/8383022 to your computer and use it in GitHub Desktop.
Make your maven output colorful to easily identify FAILURES and look a bit easier on the eye.
PURPLE=$(echo -en "\033[35m")
GREEN=$(echo -en "\033[32m")
RED=$(echo -en "\033[31m")
BLUE=$(echo -e "\033[1;34m")
NORMAL=$(echo -e "\033[0m")
mvn2() {
mvn $* | sed \
-e "
s/^\(Failed tests:.*\)$/$RED\1$NORMAL/; # contains 'Failed tests:'
s/^\(.*\b[S][U][C][C][E][S][S]\b.*\)$/$GREEN\1$NORMAL/; # contains SUCCESS somewhere in the message
s/^\(.*\b[S][K][I][P][P][E][D]\b.*\)$/$PURPLE\1$NORMAL/;# contains SKIPPED somewhere in the message
s/^\(.*\bWARNING\b.*\)$/$PURPLE\1$NORMAL/; # contains WARNING somewhere in the message
s/^\(\bWARN\b.*\)$/$PURPLE\1$NORMAL/; # contains WARN somewhere in the message
s/^\(.*\bERROR\b.*\)$/$RED\1$NORMAL/; # contains ERROR somewhere in the message
s/^\(.*\bFAILURE\b.*\)$/$RED\1$NORMAL/; # contains FAILURE somewhere in the message
s/^\(Caused by*.*\)$/$RED\1$NORMAL/; # starts with 'Caused by'
s/^\(\tat .*\)$/$RED\1$NORMAL/; # starts with 'at ...' (stack trace)
s/^\(Tests run\b.*\)$/${BLUE}\1${NORMAL}/; # start with 'Tests run'
"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment