-
Notifications
You must be signed in to change notification settings - Fork 0
/
difftoolpdf.sh
56 lines (44 loc) · 1.35 KB
/
difftoolpdf.sh
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash
# Requires:
# git
# latexdiff
# latexmk
# Usage: difftoolpdf.sh <old> [<new>]
# Old and new can be any commit reference recognized by git checkout.
# E.g., difftoolpdf.sh v1.0 v1.1
# If <new> is omitted, use the current branch & commit.
# the directory of the script
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# the temp directory used, within $DIR
# omit the -p parameter to create a temporal directory in the default location
WORK_DIR=`mktemp -d -p "$DIR"`
# check if tmp dir was created
if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then
echo "Could not create temp dir"
exit 1
fi
# deletes the temp directory
function cleanup {
rm -rf "$WORK_DIR"
echo "Deleted temp working directory $WORK_DIR"
}
# register the cleanup function to be called on the EXIT signal
trap cleanup EXIT
git worktree add $WORK_DIR/old --no-checkout --detach
cd $WORK_DIR/old
git checkout $1
make tex --quiet
cd $DIR
git worktree add $WORK_DIR/new --no-checkout --detach
cd $WORK_DIR/new
git checkout $2
make tex --quiet
cd $DIR
latexdiff --preamble=pdfcomment.tex \
$WORK_DIR/old/print/Richland_Prefab_2BR.tex $WORK_DIR/new/print/Richland_Prefab_2BR.tex \
> $DIR/print/Richland_Prefab_2BR_diff.tex
git worktree remove $WORK_DIR/old
git worktree remove $WORK_DIR/new
cd $DIR/print
latexmk -quiet -xelatex Richland_Prefab_2BR_diff.tex
latexmk -c