Skip to content

Instantly share code, notes, and snippets.

@DanielThomas
Forked from mike-ensor/colorize-maven.sh
Created December 3, 2012 19:25

Revisions

  1. Danny Thomas revised this gist Dec 3, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions colorize-maven.sh
    Original file line number Diff line number Diff line change
    @@ -86,7 +86,7 @@ color_maven() {
    fi

    error=${c_bold}${c_red}
    info=${c_white}
    info=${c_end}
    warn=${c_yellow}
    success=${c_green}
    projectname=${c_bold}${c_cyan}
    @@ -104,7 +104,7 @@ color_maven() {
    -e "s/FAILURE (\[[0-9]+.[:0-9]+s\])/${error}FAILURE \1${c_end}/g" \
    -e "s/SUCCESS (\[[0-9]+.[:0-9]+s\])/${success}SUCCESS \1${c_end}/g" \
    -e "s/(\[INFO.*)/${info}\1${c_end}/g" \
    -e "s/INFO: (.+)/${c_white}INFO: \1${c_end}/g" \
    -e "s/INFO: (.+)/${info}INFO: \1${c_end}/g" \
    -e "s/(\[WARN.*)/${warn}\1${c_end}/g" \
    -e "s/(\[ERROR.*)/${error}\1${c_end}/g" \
    -e "s/(<<< FAILURE!)/${error}\1${c_end}/g" \
  2. Danny Thomas revised this gist Dec 3, 2012. 1 changed file with 0 additions and 0 deletions.
    Empty file modified colorize-maven.sh
    100644 → 100755
    Empty file.
  3. Danny Thomas revised this gist Dec 3, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions colorize-maven.sh
    Original file line number Diff line number Diff line change
    @@ -75,7 +75,7 @@ ansi_color() {
    color_maven() {

    # pick color type
    if [ $TERM = 'xterm-color' ]
    if [[ $TERM = 'xterm-color' || $TERM = 'xterm-256color' ]]
    then
    xterm_color
    # elif [ $TERM = 'ansi' ]
    @@ -93,7 +93,7 @@ color_maven() {
    skipped=${c_white}
    downloading=${c_magenta}

    $MAVEN_HOME/bin/mvn $* | sed -e "s/(\[INFO\]) Building( .*)/${info}\1${projectname}\2${c_end}/g" \
    $MAVEN_HOME/bin/mvn $* | sed -E -e "s/(\[INFO\]) Building( .*)/${info}\1${projectname}\2${c_end}/g" \
    -e "s/(Time elapsed: )([0-9]+[.]*[0-9]*.sec)/${c_cyan}\1${c_white}\2${c_end}/g" \
    -e "s/(Downloading: .*)/${downloading}\1${c_end}/g" \
    -e "s/BUILD FAILURE/${error}BUILD FAILURE${c_end}/g" \
  4. @mike-ensor mike-ensor revised this gist Feb 22, 2012. 1 changed file with 17 additions and 17 deletions.
    34 changes: 17 additions & 17 deletions colorize-maven.sh
    Original file line number Diff line number Diff line change
    @@ -42,23 +42,23 @@ xterm_color() {
    # Yes, this could be a map
    c_bold=`tput setaf 0`
    c_bg_bold=`tput setab 0`
    c_black=`tput setab 0`
    c_bg_black=`tput setab 0`
    c_cyan=`tput setaf 6`
    c_bg_cyan=`tput setab 6`
    c_magenta=`tput setaf 5`
    c_bg_magenta=`tput setab 5`
    c_red=`tput setaf 1`
    c_bg_red=`tput setab 1`
    c_white=`tput setaf 7`
    c_bg_white=`tput setab 7`
    c_green=`tput setaf 2`
    c_bg_green=`tput setab 2`
    c_yellow=`tput setaf 3`
    c_black=`tput setab 0`
    c_bg_black=`tput setab 0`
    c_cyan=`tput setaf 6`
    c_bg_cyan=`tput setab 6`
    c_magenta=`tput setaf 5`
    c_bg_magenta=`tput setab 5`
    c_red=`tput setaf 1`
    c_bg_red=`tput setab 1`
    c_white=`tput setaf 7`
    c_bg_white=`tput setab 7`
    c_green=`tput setaf 2`
    c_bg_green=`tput setab 2`
    c_yellow=`tput setaf 3`
    c_bg_yellow=`tput setab 3`
    c_blue=`tput setaf 4`
    c_bg_blue=`tput setab 4`
    c_end=`tput sgr0`
    c_blue=`tput setaf 4`
    c_bg_blue=`tput setab 4`
    c_end=`tput sgr0`
    }

    ansi_color() {
    @@ -108,7 +108,7 @@ color_maven() {
    -e "s/(\[WARN.*)/${warn}\1${c_end}/g" \
    -e "s/(\[ERROR.*)/${error}\1${c_end}/g" \
    -e "s/(<<< FAILURE!)/${error}\1${c_end}/g" \
    -e "s/Tests run: ([0-9]*), Failures: ([0-9]*), Errors: ([0-9]*), Skipped: ([0-9]*)/${c_green}Tests run: \1${c_end}, Failures: ${warn}\2${c_end}, Errors: ${error}\3${c_end}, Skipped: ${skipped}\4${c_end}/g"
    -e "s/Tests run: ([0-9]*), Failures: ([0-9]*), Errors: ([0-9]*), Skipped: ([0-9]*)/${c_green}Tests run: \1 ${c_end}, Failures: ${warn}\2 ${c_end}, Errors: ${error}\3 ${c_end}, Skipped: ${skipped}\4 ${c_end}/g"
    }

    alias mvn=color_maven
  5. @mike-ensor mike-ensor created this gist Feb 22, 2012.
    114 changes: 114 additions & 0 deletions colorize-maven.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,114 @@
    #!/bin/sh

    # Written by Mike Ensor ([email protected])
    # Copywrite 2012
    # Use as needed, modify, have fun!
    # This is intended to be used for Maven3 + Mac OSX
    #
    # To use:
    # in your ".bashrc" or ".bash_profile" add the following line:
    # source ~/<path to script>/colorize-maven.sh
    #

    c_black=
    c_cyan=
    c_magenta=
    c_red=
    c_white=
    c_green=
    c_yellow=
    c_blue=
    c_bg_black=
    c_bg_cyan=
    c_bg_magenta=
    c_bg_red=
    c_bg_white=
    c_bg_green=
    c_bg_yellow=
    c_bg_blue=
    c_end=
    c_bold=

    xterm_color() {
    # 0 Black
    # 1 Red
    # 2 Green
    # 3 Yellow
    # 4 Blue
    # 5 Magenta
    # 6 Cyan
    # 7 White

    # Yes, this could be a map
    c_bold=`tput setaf 0`
    c_bg_bold=`tput setab 0`
    c_black=`tput setab 0`
    c_bg_black=`tput setab 0`
    c_cyan=`tput setaf 6`
    c_bg_cyan=`tput setab 6`
    c_magenta=`tput setaf 5`
    c_bg_magenta=`tput setab 5`
    c_red=`tput setaf 1`
    c_bg_red=`tput setab 1`
    c_white=`tput setaf 7`
    c_bg_white=`tput setab 7`
    c_green=`tput setaf 2`
    c_bg_green=`tput setab 2`
    c_yellow=`tput setaf 3`
    c_bg_yellow=`tput setab 3`
    c_blue=`tput setaf 4`
    c_bg_blue=`tput setab 4`
    c_end=`tput sgr0`
    }

    ansi_color() {
    c_bold= '[1m'
    c_blue= '[1;34m'
    c_black= '[1;30m'
    c_green= '[1;32m'
    c_magenta='[1;35m'
    c_red= '[1;31m'
    c_cyan= '[1;36m'
    c_end= '[0m'
    }

    color_maven() {

    # pick color type
    if [ $TERM = 'xterm-color' ]
    then
    xterm_color
    # elif [ $TERM = 'ansi' ]
    # then
    # ansi_color
    else
    echo "${c_red}WARNING:::Terminal '${TERM}' is not supported at this time. Colorized output will not happen for Maven${c_end}"
    fi

    error=${c_bold}${c_red}
    info=${c_white}
    warn=${c_yellow}
    success=${c_green}
    projectname=${c_bold}${c_cyan}
    skipped=${c_white}
    downloading=${c_magenta}

    $MAVEN_HOME/bin/mvn $* | sed -e "s/(\[INFO\]) Building( .*)/${info}\1${projectname}\2${c_end}/g" \
    -e "s/(Time elapsed: )([0-9]+[.]*[0-9]*.sec)/${c_cyan}\1${c_white}\2${c_end}/g" \
    -e "s/(Downloading: .*)/${downloading}\1${c_end}/g" \
    -e "s/BUILD FAILURE/${error}BUILD FAILURE${c_end}/g" \
    -e "s/WARNING: ([a-zA-Z0-9.-/\\ :]+)/${warn}WARNING: \1${c_end}/g" \
    -e "s/SEVERE: (.+)/${c_white}${c_bg_red}SEVERE: \1${c_end}/g" \
    -e "s/Caused by: (.+)/${c_white}${c_bg_green}Caused by: \1${c_end}/g" \
    -e "s/Running (.+)/${c_green}Running \1${c_end}/g" \
    -e "s/FAILURE (\[[0-9]+.[:0-9]+s\])/${error}FAILURE \1${c_end}/g" \
    -e "s/SUCCESS (\[[0-9]+.[:0-9]+s\])/${success}SUCCESS \1${c_end}/g" \
    -e "s/(\[INFO.*)/${info}\1${c_end}/g" \
    -e "s/INFO: (.+)/${c_white}INFO: \1${c_end}/g" \
    -e "s/(\[WARN.*)/${warn}\1${c_end}/g" \
    -e "s/(\[ERROR.*)/${error}\1${c_end}/g" \
    -e "s/(<<< FAILURE!)/${error}\1${c_end}/g" \
    -e "s/Tests run: ([0-9]*), Failures: ([0-9]*), Errors: ([0-9]*), Skipped: ([0-9]*)/${c_green}Tests run: \1${c_end}, Failures: ${warn}\2${c_end}, Errors: ${error}\3${c_end}, Skipped: ${skipped}\4${c_end}/g"
    }

    alias mvn=color_maven