My configurations for the software I use

typp: add script for previewing typst files when they change

yemou.pink e707438e 3e016e39

verified
Changed files
+35
local
bin
+35
local/bin/typp
···
···
+
#!/bin/sh
+
set -e
+
+
file=$1
+
if [ "$file" = "typ" ] || [ "${file##*.}" != "typ" ] || [ ! -e "$file" ]
+
then
+
printf '%s\n' "Missing typst file"
+
exit 1
+
fi
+
+
pdf="${1%.typ}.pdf"
+
+
# Generate a blank PDF document so sioyek doesn't segfault
+
magick convert xc:none -page A4 "$pdf"
+
+
# typst watch "$file" > /dev/null 2>&1 &
+
typst watch "$file" &
+
typst_pid="$!"
+
+
sioyek "$pdf" > /dev/null 2>&1 &
+
sioyek_pid="$!"
+
+
kill_children() {
+
kill $typst_pid
+
kill $sioyek_pid
+
exit
+
}
+
+
trap kill_children EXIT
+
+
while inotifywait -e close_write,moved_to,create -qq "$pdf"
+
do sioyek --execute-command reload_no_flicker > /dev/null 2>&1
+
done
+
+
kill_children