March 31, 2010

Ant Color Coding in bash

If you add this function to your .bash_profile or .bashrc it will enable ant color coding. The sed scripts highlight your junit tests.


function ant {
RED=`echo -e '\033[1;41m\033[37m'`
GREEN=`echo -e '\033[1;42m\033[37m'`
NORMAL=`echo -e '\033[0m'`

$ANT_HOME/bin/ant -logger org.apache.tools.ant.listener.AnsiColorLogger $* | \
sed \
-e "s/\(FAILED\)/$RED\1$NORMAL/" \
-e "s/\(.*Failures: [123456789].*\)/$RED\1$NORMAL/" \
-e "s/\(.*Errors: [123456789].*\)/$RED\1$NORMAL/" \
-e "s/\(.*Failures: 0, Errors: 0.*\)/$GREEN\1$NORMAL/" \

}

No comments: