Skip to content

Instantly share code, notes, and snippets.

@jasonmc
Created November 17, 2011 20:12
Show Gist options
  • Save jasonmc/1374358 to your computer and use it in GitHub Desktop.
Save jasonmc/1374358 to your computer and use it in GitHub Desktop.
A script that uses inotiftwait to look for changes in all files with given extension, and run specifed command. Useful for compiling LaTeX.
onchangerecur . 'pdflatex -interaction batchmode thesis.tex' .tex
#!/bin/sh
PLACE="$1"
COMMAND="$2"
EXT="$3"
inotifywait -rqme CLOSE_WRITE --format '%f' $PLACE | while read f;
do
if echo "$f" | grep $EXT$; then
sh -c "$COMMAND"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment