diff options
author | Jan Pokorný <jpokorny@redhat.com> | 2013-04-19 16:19:46 +0200 |
---|---|---|
committer | Jan Pokorný <jpokorny@redhat.com> | 2013-04-19 16:19:46 +0200 |
commit | e8f4d4a7eec464192363d3f73d8b005e1abe2ead (patch) | |
tree | 8e46f7299865607f6d27a4c41ec9edd8f875baa4 | |
parent | 3dc78a363e38badf4d8304789f95f23f1ed84c2b (diff) | |
download | watch-bz-e8f4d4a7eec464192363d3f73d8b005e1abe2ead.tar.gz watch-bz-e8f4d4a7eec464192363d3f73d8b005e1abe2ead.tar.xz watch-bz-e8f4d4a7eec464192363d3f73d8b005e1abe2ead.zip |
utilize support for colors in watch util if available
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
-rwxr-xr-x | watch-bz | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -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 |