Last active
July 18, 2017 18:46
-
-
Save staslev/f159d0c55a750b5a68a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# mvn-color based on https://gist.github.com/1027800 and https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/mvn | |
export BOLD=`tput bold` | |
export UNDERLINE_ON=`tput smul` | |
export UNDERLINE_OFF=`tput rmul` | |
export TEXT_BLACK=`tput setaf 0` | |
export TEXT_RED=`tput setaf 1` | |
export TEXT_GREEN=`tput setaf 2` | |
export TEXT_YELLOW=`tput setaf 3` | |
export TEXT_BLUE=`tput setaf 4` | |
export TEXT_MAGENTA=`tput setaf 5` | |
export TEXT_CYAN=`tput setaf 6` | |
export TEXT_WHITE=`tput setaf 7` | |
export BACKGROUND_BLACK=`tput setab 0` | |
export BACKGROUND_RED=`tput setab 1` | |
export BACKGROUND_GREEN=`tput setab 2` | |
export BACKGROUND_YELLOW=`tput setab 3` | |
export BACKGROUND_BLUE=`tput setab 4` | |
export BACKGROUND_MAGENTA=`tput setab 5` | |
export BACKGROUND_CYAN=`tput setab 6` | |
export BACKGROUND_WHITE=`tput setab 7` | |
export RESET_FORMATTING=`tput sgr0` | |
# Wrapper function for Maven's mvn command. | |
mvn-color() | |
{ | |
( | |
# Filter mvn output using sed. Before filtering set the locale to C, so invalid characters won't break some sed implementations | |
unset LANG | |
LC_CTYPE=C mvn $@ | sed -e "s/\(.* BUILD SUCCESS\)/${BOLD}${TEXT_GREEN}\1${RESET_FORMATTING}/g" \ | |
-e "s/\(.* BUILD FAILURE\)/${BOLD}${TEXT_RED}\1${RESET_FORMATTING}/g" \ | |
-e "s/\(.*\.\. FAILURE \[.*\]\)/${BOLD}${TEXT_RED}\1${RESET_FORMATTING}/g" \ | |
-e "s/\(\[INFO\] Building [^:]*$\)/${BOLD}${TEXT_BLUE}\1${RESET_FORMATTING}/g" \ | |
-e "s/\(\[WARNING\] .*\)/${BOLD}${TEXT_YELLOW}\1${RESET_FORMATTING}/g" \ | |
-e "s/\(\[ERROR\] .*\)/${BOLD}${TEXT_RED}\1${RESET_FORMATTING}/g" \ | |
-e "s/\(.* Total time:.*\)\(.*\)/${BOLD}${TEXT_CYAN}\1${RESET_FORMATTING}/g" \ | |
-e "s/Tests run: \([^,]*\), Failures: \([^,]*\), Errors: \([^,]*\), Skipped: \([^,]*\)/${TEXT_GREEN}Tests run: \1${RESET_FORMATTING}, Failures: ${BOLD}${TEXT_RED}\2${RESET_FORMATTING}, Errors: ${BOLD}${TEXT_RED}\3${RESET_FORMATTING}, Skipped: ${BOLD}${TEXT_YELLOW}\4${RESET_FORMATTING}/g" | |
# Make sure formatting is reset | |
echo -ne ${RESET_FORMATTING} | |
) | |
} | |
alias mvn='mvn-color' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment