Last active
August 29, 2015 14:10
-
-
Save AndrewKvalheim/fb42f94de7f05a650b3c to your computer and use it in GitHub Desktop.
Git diff driver for Anki decks
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
*.apkg diff=apkg |
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
[core] | |
attributesfile = ~/.gitattributes_global | |
[diff "apkg"] | |
textconv = ~/bin/apkg-conv.sh | |
cachetextconv = true |
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 | |
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