This feels like a situation where I need to watch a stream (stdin), if a line comes in, wait a moment, then fire the command and wait some more.
Using a tool like pyinotify or fswatch, we can watch a folder for changes and when one is found, echo it out.
fswatch --recursive --latency 2 src/ | xargs make build
or
pyinotify -r -a -e IN_CLOSE_WRITE -c 'make build' src/
In my case, I am trying to figure out how to call make build whenever a file changes. While the above tools do work, they can end up calling make build a lot and in rapid succession. Each tool works a little bit differently, but the end result is the same (make is getting called too much)
I need all of the gyrating to stop, 1 second to elapse, and then invoke make just one time.
Is there some unix way to batch up the commands and then invoke make? Something like this:
fswatch --recursive src/ | aggregate_and_wait --delay 1second | make build
sleep 1up at the top somewhere. Have yourfswatchorpyinotifycall that script.