Skip to content

Instantly share code, notes, and snippets.

@AndrewKvalheim
Last active August 29, 2015 14:10
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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