fswatch
is a good program to react to file changes, e.g. run tests when files
are updated. It's cross-platform.
fswatch path/to/file | xargs -n 1 bash_command
fswatch ./README.md | xargs -I {} -n 1 pandoc -o README.html README.md
fswatch -o ./*.js | xargs -I {} -n 1 npm test
See tldr fswatch
for more examples. Use -v/--verbose
to double-check that
stuff is happening. -I {}
is needed to either insert the filename in a
particular place, or to not put it in at the end of the command.
-o/--one-per-batch
will batch changes together to one alert when many files
are changed at the same time. -n 1
is only necessary if you are watching more
than one file I think.