forked from leoheck/kiri
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-imgdiff
More file actions
executable file
·28 lines (21 loc) · 913 Bytes
/
git-imgdiff
File metadata and controls
executable file
·28 lines (21 loc) · 913 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
# Remove random number from the filename
svg_new_1=$(basename "$1" | sed "s|from_\(.*\)\([0-9a-f]\{6\}\).svg|sch1-\1.svg|g")
svg_new_2=$(basename "$2" | sed "s|to_\(.*\)\([0-9a-f]\{6\}\).svg|sch2-\1.svg|g")
# Extract random number from the filename
hash_1=$(basename "$1" | sed "s|from_.*\([0-9a-f]\{6\}\).svg|\1|g")
hash_2=$(basename "$2" | sed "s|to_.*\([0-9a-f]\{6\}\).svg|\1|g")
# Rename originals filename: remove /tmp and keep the random number
orig_1=$(basename "$1" | sed "s|from_\(.*\)\([0-9a-f]\{6\}\).svg|sch1-\1-\2.svg|g")
orig_2=$(basename "$2" | sed "s|to_\(.*\)\([0-9a-f]\{6\}\).svg|sch2-\1-\2.svg|g")
# Keep originals
if [[ "$PLOTGITSH_KEEP_ORIGINALS" == "1" ]]; then
mv -f "$1" "$orig_1"
mv -f "$2" "$orig_2"
fi
echo "Exporting..."
echo "$svg_new_1 (${hash_1})"
echo "$svg_new_2 (${hash_2})"
cp -f "$1" "$svg_new_1" > /dev/null
cp -f "$2" "$svg_new_2" > /dev/null
echo