From 2556522c228baa4a1643037f8791521aefa435e4 Mon Sep 17 00:00:00 2001 From: Ismael Barros Date: Sun, 15 Dec 2013 22:06:43 +0100 Subject: [PATCH] colorpipe --- util.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/util.sh b/util.sh index 37c8491..5be7ca9 100755 --- a/util.sh +++ b/util.sh @@ -9,6 +9,9 @@ NORMAL=$'\e[0m' HILITE=$'\e[36;01m' BRACKET=$'\e[34;01m' +# http://stackoverflow.com/questions/6841143/how-to-set-font-color-for-stdout-and-stderr +color()(set -o pipefail;"$@" 2>&1>&3|sed $'s,.*,\e[31m&\e[m,'>&2)3>&1 + die() { echo -e ${BAD}$@${NORMAL}; exit 1; } trimp() { sed -e 's/^[ \t]*//g' -e 's/[ \t]*$//g'; } trim() { echo $@ | trimp; }