Skip to content

Instantly share code, notes, and snippets.

@brunobmello25
Created June 24, 2024 20:51
Show Gist options
  • Select an option

  • Save brunobmello25/6f930da76ef05fa8442e9bb4ed575955 to your computer and use it in GitHub Desktop.

Select an option

Save brunobmello25/6f930da76ef05fa8442e9bb4ed575955 to your computer and use it in GitHub Desktop.
bash script to auto recompile latex file when changes happen
# please install dependencies first:
# sudo apt update && sudo apt install textlive-full inotify-tools
#
# USAGE: ./run.sh ./tex-directory/texfile.tex
# -------------------------------------------------------------
#!/bin/bash
FILE=$1
DIR=$(dirname "$FILE")
BASENAME=$(basename "$FILE" .tex)
inotifywait -m -e close_write "$DIR" |
while read -r directory events filename; do
if [ "$filename" == "$BASENAME.tex" ]; then
pdflatex -interaction=nonstopmode -synctex=1 -output-directory="$DIR" "$FILE"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment