I have been working on stuff in latex recently and wanted something to trigger regeneration of pdfs without manual intervention. At first I thought about doing so in a loop every so often, but it didn't seem like the best approach.

Knowing about the cool kqueue framework I looked to see if there was a utility to watch files for me. I found the wait_on command via a FreeBSD forums post.

The wait_on command will wait until the watched file has been changed and then exit. It is meant to be used within a loop. I through this together in zsh. Now when I :wq in vim wait_on exists and my document rebuilds, evinces picks up on this and refreshes the display.

$ while true; do wait_on pres.tex; xelatex pres.tex; sleep 5; done

I have the sleep at the end to stop the document being built too often.