LaTeX_Files/cover letter/build.sh

37 lines
743 B
Bash
Raw Normal View History

2024-10-16 16:48:20 +02:00
#!/usr/bin/env bash
OUTPUT_DIR=".out"
FILE="main"
compile_latex() {
mkdir -p "$OUTPUT_DIR" # if does not exist
rm -rf "$OUTPUT_DIR/*" # if exist and full
rsync -av --exclude="$OUTPUT_DIR" ./ "$OUTPUT_DIR" > /dev/null 2>&1
cd "$OUTPUT_DIR" || exit
if ! pdflatex --interaction=nonstopmode "$FILE.tex" > error.log 2>&1; then
echo "Compilation failed. Check error.log for details."
else
echo "Compilation successful."
rm error.log
fi
cd .. || exit
}
compile_latex
zathura "$OUTPUT_DIR/$FILE.pdf" &
while true; do
inotifywait -e modify -e create -e delete -r . --include '.*\.tex' > /dev/null 2>&1
echo "Change detected. Compiling LaTeX files..."
compile_latex
done