Skip to content

Instantly share code, notes, and snippets.

@islomar
Created February 28, 2014 08:17
Show Gist options
  • Save islomar/9267285 to your computer and use it in GitHub Desktop.
Save islomar/9267285 to your computer and use it in GitHub Desktop.
Show Maven CLI with color
# Colorize Maven Output
# Colors reference: http://en.wikipedia.org/wiki/ANSI_escape_code
color_maven() {
$M2_HOME/bin/mvn $* | sed \
-e 's/Tests run: \([^,]*\), Failures: \([^,]*\), Errors: \([^,]*\), Skipped: \([^,]*\)/^[[32;1mTests run: \1^[[0m, Failures: ^[[31;1m\2^[[0m, Errors: ^[[33;1m\3^[[0m, Skipped: ^[[34;1m\4^[[0m/g' \
-e 's/\(\[INFO\] \-[-]*$\)/^[[36;1m\1^[[0m/g' \
-e 's/\(\[INFO\] Building.*\)/^[[36;1m\1^[[0m/g' \
-e 's/\(.*WARN.*\)/^[[33;1m\1^[[0m/g' \
-e 's/\(.*ERROR.*\)/^[[31;1m\1^[[0m/g' \
-e 's/\(Downloaded:.*\)/^[[32;1m\1^[[0m/g'
}
alias mvn=color_maven
alias maven=$M2_HOME/bin/mvn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment