From e8f4d4a7eec464192363d3f73d8b005e1abe2ead Mon Sep 17 00:00:00 2001 From: Jan Pokorný Date: Fri, 19 Apr 2013 16:19:46 +0200 Subject: utilize support for colors in watch util if available MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan Pokorný --- watch-bz | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/watch-bz b/watch-bz index c118d71..a2eae5f 100755 --- a/watch-bz +++ b/watch-bz @@ -32,6 +32,18 @@ BZPASSWORD= # user configuration [ -f ~/.watchbzrc ] && source ~/.watchbzrc +# Fedora and color-friendly watch: rhbz#801626 +WATCHCMD=watch +COLORIZE=cat +if watch --color -n0.1 -g date &>/dev/null; then + WATCHCMD='watch --color' + COLORIZE="sed" + COLORIZE+=" -e 's|\([0-9.A-Z]\++[, ]\)|\x1b[1;32m\1\x1b[0m|g'" + COLORIZE+=" -e 's|\([0-9.A-Z]\+-[, ]\)|\x1b[35m\1\x1b[0m|g'" + COLORIZE+=" -e 's|\([0-9.A-Z]\+?[, ]\)|\x1b[37m\1\x1b[0m|g'" + COLORIZE+=" -e 's|\(!!!\)|\x1b[1;31m\1\x1b[0m|g'" +fi + # guess correct paths if [ -z "$BUGZILLA" ] || [ -n "${BUGZILLA_ROOT}" ]; then # BUGZILLA_ROOT (path to local repo) should rather be set in ~/.watchbzrc @@ -86,7 +98,7 @@ do_init () { # exclusively using globals do_watch () { #sh -c \ - watch -t --interval $REFRESH_INTERVAL --differences=cumulative \ + ${WATCHCMD} -t --interval $REFRESH_INTERVAL --differences=cumulative \ "$BUGZILLA --cookiefile="${BUGZILLA_COOKIE}" query -c $COMPONENT \ -t $STATUS --outputformat $OUTPUT_FMT \ | sed -u \ @@ -117,9 +129,7 @@ do_watch () { -e \"s|rhel-||g\" \ -e \"s|qe_test_coverage||\" \ -e \"s|None||\" \ - | ${HERE}/table-data $SEP | sort | cut -c-$WIDTH" - # todo: colours for priorities (rhbz#801626) - #-e 's/\(urgent\)/\^\[\[31m\1\^\[\[0m/' \ + | ${HERE}/table-data $SEP | sort | cut -c-$WIDTH | ${COLORIZE}" } do_init -- cgit