006b88209872f5f26c57fbb8c0e5d17d5e1ddd9d
- Author
- Marc Cornellà <marc.cornella@live.com>
- Committer
- Marc Cornellà <marc.cornella@live.com>
- Date
Message
mvn: clean up mvn-color function
Diff
1diff --git a/plugins/mvn/mvn.plugin.zsh b/plugins/mvn/mvn.plugin.zsh
2index 1bc678b745e2794e23e24a174afaade7c2a4dccd..7e31da46a1624e4e66657a073c0722ba79e94106 100644
3--- a/plugins/mvn/mvn.plugin.zsh
4+++ b/plugins/mvn/mvn.plugin.zsh
5@@ -1,25 +1,3 @@
6-# mvn-color based on https://gist.github.com/1027800
7-BOLD=$(echoti bold)
8-UNDERLINE_ON=$(echoti smul)
9-UNDERLINE_OFF=$(echoti rmul)
10-TEXT_BLACK=$(echoti setaf 0)
11-TEXT_RED=$(echoti setaf 1)
12-TEXT_GREEN=$(echoti setaf 2)
13-TEXT_YELLOW=$(echoti setaf 3)
14-TEXT_BLUE=$(echoti setaf 4)
15-TEXT_MAGENTA=$(echoti setaf 5)
16-TEXT_CYAN=$(echoti setaf 6)
17-TEXT_WHITE=$(echoti setaf 7)
18-BACKGROUND_BLACK=$(echoti setab 0)
19-BACKGROUND_RED=$(echoti setab 1)
20-BACKGROUND_GREEN=$(echoti setab 2)
21-BACKGROUND_YELLOW=$(echoti setab 3)
22-BACKGROUND_BLUE=$(echoti setab 4)
23-BACKGROUND_MAGENTA=$(echoti setab 5)
24-BACKGROUND_CYAN=$(echoti setab 6)
25-BACKGROUND_WHITE=$(echoti setab 7)
26-RESET_FORMATTING=$(echoti sgr0)
27-
28 # if found an executable ./mvnw file execute it otherwise execute orignal mvn
29 mvn-or-mvnw() {
30 if [ -x ./mvnw ]; then
31@@ -31,13 +9,21 @@ mvn-or-mvnw() {
32 }
33
34 # Wrapper function for Maven's mvn command.
35+# based on https://gist.github.com/1027800
36 mvn-color() {
37+ local BOLD=$(echoti bold)
38+ local TEXT_RED=$(echoti setaf 1)
39+ local TEXT_GREEN=$(echoti setaf 2)
40+ local TEXT_YELLOW=$(echoti setaf 3)
41+ local TEXT_BLUE=$(echoti setaf 4)
42+ local TEXT_WHITE=$(echoti setaf 7)
43+ local RESET_FORMATTING=$(echoti sgr0)
44 (
45 # Filter mvn output using sed. Before filtering set the locale to C, so invalid characters won't break some sed implementations
46 unset LANG
47 LC_CTYPE=C mvn "$@" | sed \
48 -e "s/\(\[INFO\]\)\(.*\)/${TEXT_BLUE}${BOLD}\1${RESET_FORMATTING}\2/g" \
49- -e "s/\(\[DEBUG\]\)\(.*\)/${TEXT_RED}${BOLD}\1${RESET_FORMATTING}\2/g" \
50+ -e "s/\(\[DEBUG\]\)\(.*\)/${TEXT_WHITE}${BOLD}\1${RESET_FORMATTING}\2/g" \
51 -e "s/\(\[INFO\]\ BUILD SUCCESSFUL\)/${BOLD}${TEXT_GREEN}\1${RESET_FORMATTING}/g" \
52 -e "s/\(\[WARNING\]\)\(.*\)/${BOLD}${TEXT_YELLOW}\1${RESET_FORMATTING}\2/g" \
53 -e "s/\(\[ERROR\]\)\(.*\)/${BOLD}${TEXT_RED}\1${RESET_FORMATTING}\2/g" \