I use this script to run a build script on changes in a directory tree:
#! /bin/bash
DIRECTORY_TO_OBSERVE="js" // might want to change this
function block_for_change {
inotifywait -r \
-e modify,move,create,delete \
$DIRECTORY_TO_OBSERVE
}
BUILD_SCRIPT=build.sh // might want to change this too
function build {
bash $BUILD_SCRIPT
}
build
while block_for_change; do
build
done
Uses inotify-tools. Check inotifywaitman page for how to customize what triggers the build.
I use this script to run a build script on changes in a directory tree:
Uses
inotify-tools
. Checkinotifywait
man page for how to customize what triggers the build.Here's another option: http://fileschanged.sourceforge.net/
See especially "example 4", which "monitors a directory and archives any new or changed files".
Add the following to ~/.bashrc:
You may try
entr
tool to run arbitrary commands when files change. Example for files:or:
For directories use
-d
, but you've to use it in the loop, e.g.:or: