File tree Expand file tree Collapse file tree 2 files changed +23
-5
lines changed Expand file tree Collapse file tree 2 files changed +23
-5
lines changed Original file line number Diff line number Diff line change 9393
9494readonly -a ECHO_COLORS=(33 35 36 31 32 37 34)
9595COUNT=0
96+ rotateColorEcho () {
97+ local message=" $* "
98+
99+ # skip color for white space
100+ if [[ " $message " =~ ^[[:space:]]* $ ]]; then
101+ echo " $message "
102+ else
103+ local color=" ${ECHO_COLORS[COUNT++ % ${#ECHO_COLORS[@]} ]}"
104+ colorEcho " $color " " $* "
105+ fi
106+ }
96107
97108for a in ${args[@]: +" ${args[@]} " } ; do
98- colorEcho " ${ECHO_COLORS[COUNT++ % ${#ECHO_COLORS[@]} ]} " " $a "
109+ rotateColorEcho " $a "
99110done
Original file line number Diff line number Diff line change @@ -21,13 +21,20 @@ readonly eend=$'\033[0m' # escape end
2121
2222readonly -a ECHO_COLORS=(33 35 36 31 32 37 34)
2323COUNT=0
24- colorEcho () {
25- local color=" ${ECHO_COLORS[COUNT++ % ${#ECHO_COLORS[@]} ]}"
26- echo " ${ec} [1;${color} m$* $eend "
24+ rotateColorEcho () {
25+ local message=" $* "
26+
27+ # skip color for white space
28+ if [[ " $message " =~ ^[[:space:]]* $ ]]; then
29+ echo " $message "
30+ else
31+ local color=" ${ECHO_COLORS[COUNT++ % ${#ECHO_COLORS[@]} ]}"
32+ echo " ${ec} [1;${color} m$message$eend "
33+ fi
2734}
2835
2936# Bash read line does not read leading spaces
3037# https://stackoverflow.com/questions/29689172
3138cat " $@ " | while IFS= read -r line; do
32- colorEcho " $line "
39+ rotateColorEcho " $line "
3340done
You can’t perform that action at this time.
0 commit comments