Created
December 27, 2019 16:12
-
-
Save timmc/4c56bbe4a36aa1bc075f7d9c776fee1f to your computer and use it in GitHub Desktop.
This file contains 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 | |
cd ~/sync/ | |
function remove_timestamps { | |
grep -v -Pe '^\+#[0-9]+$' - | |
} | |
function baseline_no_ts { | |
git show HEAD:home/.bash_history | remove_timestamps | |
} | |
function history_diff_no_ts { | |
git diff --unified=0 --inter-hunk-context=0 -- home/.bash_history \ | |
| tail -n +6 \ | |
| remove_timestamps | |
} | |
function removals { | |
history_diff_no_ts \ | |
| grep -e '^-' \ | |
| sed 's/^-//' | |
} | |
function additions { | |
history_diff_no_ts \ | |
| grep -e '^+' \ | |
| sed 's/^+//' | |
} | |
function list_changes { | |
echo "Removals" | |
echo "========" | |
echo | |
removals | |
echo | |
echo "Additions" | |
echo "=========" | |
echo | |
comm -13 <(baseline_no_ts | sort | uniq) <(additions | sort | uniq) | |
} | |
list_changes | less |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment