Skip to content

Instantly share code, notes, and snippets.

@sxlijin
Created December 25, 2016 20:30
Show Gist options
  • Save sxlijin/af73baa72a0f32bf354469468720b1d6 to your computer and use it in GitHub Desktop.
Save sxlijin/af73baa72a0f32bf354469468720b1d6 to your computer and use it in GitHub Desktop.
monitor a directory tree with inotifywait, repeat a command when anything in the tree changes
#!/bin/bash
WATCH_DIR="app/"
REPEAT_ON_CHANGES="./node_modules/.bin/webpack --progress"
inotifywait -m --exclude '\..*.swp' -e MODIFY -r $WATCH_DIR | \
while true
do
sleep 0.1
(e=false; while read -t 0.1 d; do echo $d; export e=true ; done; $e) \
&& $REPEAT_ON_CHANGES
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment