Skip to content

Instantly share code, notes, and snippets.

@gdetrez
Created June 27, 2013 15:25
Show Gist options
  • Save gdetrez/5877405 to your computer and use it in GitHub Desktop.
Save gdetrez/5877405 to your computer and use it in GitHub Desktop.
Poor man's guard: a simple, one line, watch function. For Makefiles or shell scripts.
watch = while true; do (inotifywait -qre close_write --format "%w%f" . | grep $1) && $2; done
all:
$(call watch, 'test/.*.txt', echo "some stuff has changed...")
#!/bin/bash
function watch {
while true; do
(inotifywait -qre close_write --format "%w%f" . | grep $1) && $2;
done
}
watch 'test/.*.txt' 'echo some stuff has changed...'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment