1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
#!/bin/bash
#
# Runs Inkscape vacuum to clean up svgs
CDIR=$(git rev-parse --show-toplevel)
echo "Running Inkscape vacuum. This may take some time..."
# Check if Inkscape is a flatpak or not
if [ $(which inkscape &>/dev/null; echo $?) == 0 ]; then
INKSCAPE='inkscape'
else
INKSCAPE='flatpak run org.inkscape.Inkscape'
fi
git diff --cached --name-status --diff-filter=ACMR | while read STATUS FILE; do
if [[ "$FILE" =~ ^.+(svg)$ ]]; then
$INKSCAPE --vacuum-defs -z $CDIR/$FILE --export-plain-svg=$CDIR/$FILE
fi
done
git add .
exit 0
|