Note: I edited this and turned it into a blog post - read that instead.
While poking around some random projects by the prolific TJ Holowaychuk, I came upon his version of watch, which simply executes a given command periodically.
The idea is to pair it with make
to run tests and automatically rebuild/recompile code. Since make
tracks dependencies and looks at file modification times, it won't do anything if the relevant source files haven't changed.
There's a program called watch
that comes with Linux, but it doesn't play as nicely with make
. In particular, it clears the screen every time the command is run. For pairing this with make
, we want new output to be printed whenever make
actually does anything, and otherwise we want it to be silent.