From bc89c7f15cac40852d5e906f30c2036cd47585e9 Mon Sep 17 00:00:00 2001 From: Matthieu Pignolet Date: Sun, 11 May 2025 19:09:35 +0400 Subject: feat: add watch functionality --- Makefile | 6 +++++- watch.sh | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100755 watch.sh diff --git a/Makefile b/Makefile index ab5803b..1671523 100644 --- a/Makefile +++ b/Makefile @@ -18,4 +18,8 @@ $(NAMES): $(%:.pdf=.tex) clean: @rm *.pdf @rm -r /tmp/*-sts-build -.PHONY: all clean \ No newline at end of file + +watch: watch.sh + ./watch.sh + +.PHONY: all clean watch \ No newline at end of file diff --git a/watch.sh b/watch.sh new file mode 100755 index 0000000..c591037 --- /dev/null +++ b/watch.sh @@ -0,0 +1,17 @@ +#!/bin/env bash + +# We first generate the PDFs from the start +make all + +# We then listen for changes +inotifywait -r -m -e modify . | + while read file_path file_event file_name; do + extension="${file_name##*.}" + # If the changed file is a TEX file + if [[ "$extension" == "tex" ]] + then + name="${file_name%%.*}" + # We call the make target in order to build it + make "$name.pdf" + fi + done -- cgit v1.2.3