Skip to content

Instantly share code, notes, and snippets.

@ibab
Created April 1, 2014 08:53
Show Gist options
  • Save ibab/9910438 to your computer and use it in GitHub Desktop.
Save ibab/9910438 to your computer and use it in GitHub Desktop.
A shell script for automatically recompiling a .tex file on Linux and viewing the result with mupdf.
#!/bin/sh
FILE=$1
red='\e[0;31m'
green='\e[0;32m'
reset='\e[0m'
mupdf ${FILE%.*}.pdf &
while true; do
inotifywait -q -e modify $FILE
lualatex --halt-on-error $FILE
ret=$?
xdotool search --class mupdf key --window %@ r > /dev/null 2>&1
if [ $ret -eq 0 ]; then
echo -e "${green}[SUCCESS]${reset}"
else
echo -e "${red}[FAILURE]${reset}"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment