Skip to content

Instantly share code, notes, and snippets.

@sbrki
Created December 2, 2019 20:39
Show Gist options
  • Save sbrki/f68c9a4d18cd5318109ffe1cb667671e to your computer and use it in GitHub Desktop.
Save sbrki/f68c9a4d18cd5318109ffe1cb667671e to your computer and use it in GitHub Desktop.
Simple bash script for compiling and live previewing LaTeX
#!/bin/bash
if [ $# -eq 0 ]
then
echo "No tex file provided"
echo "Usage: ./autotex.sh file.tex"
exit
fi
zathura $(echo $1 | sed "s/tex/pdf/") & # run the pdf viewer
inotifywait -m -e close_write $1 | # listen for file events
while read -r filename event; do
pdflatex --halt-on-error $1 # compile pdf
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment