Skip to content

Instantly share code, notes, and snippets.

@AndrewKvalheim
Last active August 29, 2015 14:10
Show Gist options
  • Save AndrewKvalheim/fb42f94de7f05a650b3c to your computer and use it in GitHub Desktop.
Save AndrewKvalheim/fb42f94de7f05a650b3c to your computer and use it in GitHub Desktop.
Git diff driver for Anki decks
[core]
attributesfile = ~/.gitattributes_global
[diff "apkg"]
textconv = ~/bin/apkg-conv.sh
cachetextconv = true
#!/bin/bash
set -o errexit
package_path="$1"
# Temp file
database_path="$(mktemp)"
function cleanup { rm -f "$database_path"; }; trap cleanup EXIT
# Filenames and checksums of package contents
unzip -lv "$package_path" | grep --invert-match '^Archive:\s'
echo
# Database dump
unzip -p "$package_path" 'collection.anki2' > "$database_path"
sqlite3 "$database_path" '.dump'
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment