From 08bec0a229810d62abcbbc5a90f49341232733ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20P=C5=82azie=C5=84ski?= Date: Fri, 25 Dec 2015 23:17:46 +0100 Subject: [PATCH] cleaner maven output --- .zshrc | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/.zshrc b/.zshrc index 63cca9d..ae7a521 100644 --- a/.zshrc +++ b/.zshrc @@ -401,21 +401,22 @@ alias su="sudo -u root -i" 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/\(-\{20,\}\)/$fg_bold[black]\1$reset_color/g" \ - -e "s/Building \(.*\)/$fg_bold[magenta]\1$reset_color/g" \ - -e "s/--- \([^@]\+\)@\(.*\) ---/-- $fg_bold[magenta]\2$reset_color - $fg_bold[cyan]\1$reset_color ---/g" \ - -e "s/\(\(BUILD \)\?SUCCESS\)/$fg_bold[green]\1$reset_color/g" \ - -e "s/\(\(BUILD \)\?FAILURE\)/$fg_bold[red]\1$reset_color/g" \ - -e "s/\(SKIPPED\)/$fg_bold[yellow]\1$reset_color/g" \ - -e "s/\(\[INFO\]\)\(.*\)/$fg_bold[blue]\1$reset_color\2/g" \ - -e "s/\(\[WARNING\]\)\(.*\)/$fg_bold[yellow]\1$reset_color\2/g" \ - -e "s/\(\[ERROR\]\)\(.*\)/$fg_bold[red]\1$reset_color\2/g" \ - -e "s/Tests run: \([^,]*\), Failures: \([^,]*\), Errors: \([^,]*\), Skipped: \([^,]*\)/$fg_bold[green]Tests run: \1$reset_color, Failures: $fg_bold[red]\2$reset_color, Errors: $fg_bold[red]\3$reset_color, Skipped: $fg_bold[yellow]\4$reset_color/g" - # Make sure formatting is reset - echo -ne "%{$reset_color%}" + mvn $@ 2>/dev/null | sed \ + -e "/^\W*$/d" \ + -e "s/\(-\{20,\}\)/$fg[black]\1$reset_color/g" \ + -e "s/Building \(.*\)/Building $fg_bold[magenta]\1$reset_color/g" \ + -e "s/--- \([^@]\+\) @ \(.*\) ---/$fg_bold[magenta]\2$reset_color - $fg_bold[cyan]\1$reset_color ---/g" \ + -e "s/\(\(BUILD \)\?SUCCESS\)/$fg_bold[green]\1$reset_color/g" \ + -e "s/\(\(BUILD \)\?FAILURE\)/$fg_bold[red]\1$reset_color/g" \ + -e "s/\(SKIPPED\)/$fg_bold[yellow]\1$reset_color/g" \ + -e "s/\(\[INFO\]\)\(.*\)/$fg_bold[blue]---$reset_color\2/g" \ + -e "s/\(\[WARNING\]\)\(.*\)/$fg_bold[yellow]>>>$reset_color\2/g" \ + -e "s/\(\[ERROR\]\)\(.*\)/$fg_bold[red]!!!$reset_color\2/g" \ + -e "s/^ T E S T S/$fg_bold[blue]~~~$reset_color /" \ + -e "s/Results :/$fg_bold[blue]~~~$reset_color Total: /" \ + -e "s/Running \([a-zA-Z0-9.]\+\)/$fg_bold[blue]~~~$reset_color Test: $fg_bold[cyan]\1$reset_color/" \ + -e "s/Tests run: \([^,]*\), Failures: \([^,]*\), Errors: \([^,]*\), Skipped: \([^,]*\)/$fg_bold[blue]~~~$reset_color Run: $fg_bold[green]\1$reset_color, Failed: $fg_bold[red]\2$reset_color, Error: $fg_bold[red]\3$reset_color, Skipped: $fg_bold[yellow]\4$reset_color/" + echo -ne "$reset_color" } alias mvn='mvn-color'