texwatch

Automatic TeX Recompilation

A Dead C Program

This page used to be about a C program. But on second thought, the whole thing is a poor implementation of an idea that can be hacked in 10 lines of shell. So, here is a saner alternative.

#!/bin/sh

TEX=  # list your main tex file here
DEP=`find . -name '*.tex' -not -name $TEX`
PDF=${TEX%.tex}.pdf

compile() {
        pdflatex $TEX < /dev/null
}

[ -e $PDF ] || compile
xpdf -remote view $PDF &

while inotifywait -qr -o /dev/null -e modify $TEX $DEP
do
        compile
        xpdf -remote view -reload
done

Modify it to your liking, for instance, to make it work with mupdf, simply replace the second command of the loop with [-e $PDF] && killall -HUP mupdf.