summaryrefslogtreecommitdiff
path: root/watch.sh
blob: d5a09f10e3d19e4a6a296a9f195e93a9462da6e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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" TEXFLAGS=--halt-on-error
    fi
   done