★ Who watches the watchmen?
• 154 words • 1 min • updated
I’ve been in love with watchexec:
Recursively monitors the current directory for changes, executing the command when a filesystem change is detected (among other event sources). By default, watchexec uses efficient kernel-level mechanisms to watch for changes.
It’s a modern version of entr.
Its usage is very simple and easy to remember:
shell
watchexec [--clear] [--] python main.py…will re-run python main.py whenever it changes on disk.
--clear will clear the screen between successive runs.
Other useful invocations:
shell
watchexec make
watchexec just
watchexec -e html,css,js make # watch the given extensions for changes
watchexec -w src make # watch the given directoryThere are various other useful command-line switches, its man page is very descriptive.
Here is a practical example when iterating on stack.py:
shell
% watchexec --clear -- python stack.py
[Running: python stack.py]
[Command was successful]
shell
% watchexec --clear -- ty check
[Running: ty check]
[Command was successful]Alternative: fswatch.