From b5dfe4bc5f200323df35a0af588c75891af1d327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sat, 26 Oct 2013 00:42:11 +0200 Subject: [PATCH] Watch Target um LaTeX automatisch zu kompellieren. --- .cmd_ok | 0 .gitignore | 3 ++- Makefile | 2 ++ bericht/Makefile | 10 +++++++++- bericht/check_cmds.sh | 13 +++++++++++-- 5 files changed, 24 insertions(+), 4 deletions(-) delete mode 100644 .cmd_ok diff --git a/.cmd_ok b/.cmd_ok deleted file mode 100644 index e69de29..0000000 diff --git a/.gitignore b/.gitignore index 0035a6d..510c849 100644 --- a/.gitignore +++ b/.gitignore @@ -26,4 +26,5 @@ *.synctex.gz *.fdb_latexmk *.fls -bericht/.cmd_ok +.cmd_ok +.inotifywait diff --git a/Makefile b/Makefile index 8c4fce0..4f62a63 100644 --- a/Makefile +++ b/Makefile @@ -5,3 +5,5 @@ all: done upload: all rsync -avcL www/ lctp@devkid.net:/ +watch: + cd bericht && make watch diff --git a/bericht/Makefile b/bericht/Makefile index b557f73..916276c 100644 --- a/bericht/Makefile +++ b/bericht/Makefile @@ -1,7 +1,15 @@ .cmd_ok: - ./check_cmds.sh + ./check_cmds.sh .cmd_ok rsync latexmk +.inotifywait: + ./check_cmds.sh .inotifywait inotifywait %.pdf: %.tex latexmk -pdf $< all: .cmd_ok bericht.pdf clean: latexmk -CA +watch: .inotifywait + echo "Abort with Ctrl+C" + while (true); do\ + inotifywait -e MOVE_SELF -e "modify" bericht.tex;\ + latexmk -pdf bericht.tex; \ + done diff --git a/bericht/check_cmds.sh b/bericht/check_cmds.sh index 6fecf7d..499428a 100755 --- a/bericht/check_cmds.sh +++ b/bericht/check_cmds.sh @@ -1,12 +1,21 @@ #!/bin/bash -NEEDED_COMMANDS="rsync latexmk" + +if [ "$#" -lt 2 ]; then + echo "USAGE: $0 file commands..." + exit 1 +fi + +FILE=$1 +shift +NEEDED_COMMANDS=$@ for cmd in ${NEEDED_COMMANDS} ; do + echo $cmd if ! command -v ${cmd} &> /dev/null ; then echo Please install ${cmd}! exit -1 fi done -touch .cmd_ok +touch $FILE