Skip to content

Instantly share code, notes, and snippets.

@sleekweasel
Last active June 29, 2026 22:12
Show Gist options
  • Select an option

  • Save sleekweasel/1f0144a7bbfe54bce42844591e2bd045 to your computer and use it in GitHub Desktop.

Select an option

Save sleekweasel/1f0144a7bbfe54bce42844591e2bd045 to your computer and use it in GitHub Desktop.
watch, but it sprawls changes as a scrolling log.
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