Skip to content

Instantly share code, notes, and snippets.

@skeggse
Created February 27, 2018 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skeggse/8f7c856a8aac7097122fa4531dce7ad9 to your computer and use it in GitHub Desktop.
Save skeggse/8f7c856a8aac7097122fa4531dce7ad9 to your computer and use it in GitHub Desktop.
similar to watch, but with diffs and timestamps (and no cli args)
#!/bin/bash
INTERVAL=1
afile="$(mktemp)"
bfile="$(mktemp)"
function show_diff() {
a="$1"
b="$2"
diff="$(git diff --no-index --color "$b" "$a" | tail -n +5)"
if [[ "$diff" != '' ]]; then
date
echo "$diff"
fi
}
"$@" | tee "$bfile"
echo
while true; do
sleep 1
"$@" > "$afile"
show_diff "$afile" "$bfile"
sleep 1
"$@" > "$bfile"
show_diff "$bfile" "$afile"
done
rm "$afile" "$bfile"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment