Skip to content

Instantly share code, notes, and snippets.

@timmc
Created December 27, 2019 16:12
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 timmc/4c56bbe4a36aa1bc075f7d9c776fee1f to your computer and use it in GitHub Desktop.
Save timmc/4c56bbe4a36aa1bc075f7d9c776fee1f to your computer and use it in GitHub Desktop.
#!/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