Created
February 27, 2018 18:28
-
-
Save skeggse/8f7c856a8aac7097122fa4531dce7ad9 to your computer and use it in GitHub Desktop.
similar to watch, but with diffs and timestamps (and no cli args)
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
#!/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