My personal favorite for this task is entr(1): http://entrproject.org/
+1 and it works on OS X as well.
Cool! Thanks for pointing that out. (edits: grammar)
My one qualm with entr is how it deals with new files. It should handle that itself, not require calling it in a loop.
I’m a huge fan of wendy(1): http://git.z3bra.org/wendy/file/README.html
So much so that it’s pretty much one of my core utilities when writing scripts these days.
I also use this when working on scientific figures generated by scripts. E.g.:
while ! unchanged figure.py; do python figure.py; done;
Nice! I recently created a script to do poor man’s hot reloading using inotifywait. When files in the GOPATH change, the project is checked to see if “go install” would update anything. If so the project is rebuilt and then the binary restarted. A dozen lines of bash goes a long way. https://gist.github.com/shanemhansen/128f5a3ea3acd5cf18c7a8a14261ed68
If that setup is for web stuff, also have a look at devd, which will do things like reload the page when the new binary is built.