Last active
June 29, 2026 22:12
-
-
Save sleekweasel/1f0144a7bbfe54bce42844591e2bd045 to your computer and use it in GitHub Desktop.
watch, but it sprawls changes as a scrolling log.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| watchh() { | |
| local cmd="$*" | |
| case "$1" in | |
| --no-hms) | |
| shift | |
| cmd="bash -c '$*' | sed -E 's/[0-2][0-9]:[0-5][0-9]:[0-5][0-9]/[no-hms]/g'" | |
| 1>&2 echo "No HMS: $*" | |
| 1>&2 echo "Becomes: $cmd" | |
| ;; | |
| esac | |
| local a=$(mktemp -t watchh_a.XXXXXX) | |
| local b=$(mktemp -t watchh_b.XXXXXX) | |
| trap 'rm -f "$a" "$b"' EXIT INT TERM | |
| echo > "$b" | |
| while true; do | |
| eval "$cmd" > "$a" 2>&1 | |
| diff -wu1 --label "" --label "" "$b" "$a" && printf "\r$(date)\r" || date | |
| cat "$a" > "$b" | |
| sleep 1 | |
| done | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment