+35
local/bin/typp
+35
local/bin/typp
···
···
1
+
#!/bin/sh
2
+
set -e
3
+
4
+
file=$1
5
+
if [ "$file" = "typ" ] || [ "${file##*.}" != "typ" ] || [ ! -e "$file" ]
6
+
then
7
+
printf '%s\n' "Missing typst file"
8
+
exit 1
9
+
fi
10
+
11
+
pdf="${1%.typ}.pdf"
12
+
13
+
# Generate a blank PDF document so sioyek doesn't segfault
14
+
magick convert xc:none -page A4 "$pdf"
15
+
16
+
# typst watch "$file" > /dev/null 2>&1 &
17
+
typst watch "$file" &
18
+
typst_pid="$!"
19
+
20
+
sioyek "$pdf" > /dev/null 2>&1 &
21
+
sioyek_pid="$!"
22
+
23
+
kill_children() {
24
+
kill $typst_pid
25
+
kill $sioyek_pid
26
+
exit
27
+
}
28
+
29
+
trap kill_children EXIT
30
+
31
+
while inotifywait -e close_write,moved_to,create -qq "$pdf"
32
+
do sioyek --execute-command reload_no_flicker > /dev/null 2>&1
33
+
done
34
+
35
+
kill_children