Another approach would be to use the Linux kernel's fantastic <i>inotify()</i> feature, which does not require running tools designed for other purposes...<p><a href="https://linux.die.net/man/7/inotify" rel="nofollow">https://linux.die.net/man/7/inotify</a><p><a href="https://en.wikipedia.org/wiki/Inotify" rel="nofollow">https://en.wikipedia.org/wiki/Inotify</a><p>There is also a less well utilized <i>fsnotify</i> feature for filesystem-wide notifications. Here is a cross-platform go implementation which also supports OSX: <a href="https://github.com/fsnotify/fsnotify" rel="nofollow">https://github.com/fsnotify/fsnotify</a>
entr is is what I eventually settled on after years of searching the perfect utility to build/run tests after file changes. After using gulp, grunt, watching_testrunner (which I eventually inherited maintainership of), watchman, watchdog (<a href="https://github.com/gorakhargosh/watchdog" rel="nofollow">https://github.com/gorakhargosh/watchdog</a>), sniffer (<a href="https://github.com/jeffh/sniffer" rel="nofollow">https://github.com/jeffh/sniffer</a>)<p>entr is cross-platform on OS X, linux <i>and</i> BSD.<p>watching_testrunner has no BSD support<p>watchman is way too big and not domain specific enough to my needs<p>sniffer worked quite well but it required having a scent.py file everywhere<p>entr keeps it all in a neat, unix like package you can pipe files to.<p>I keep some example usage in my book, <i>The Tao of tmux</i> at <a href="https://leanpub.com/the-tao-of-tmux/read#leanpub-auto-file-watching" rel="nofollow">https://leanpub.com/the-tao-of-tmux/read#leanpub-auto-file-w...</a>. In this section I demonstrate my workflow with entr(1) in a Makefile. The code I use in the example should work across OS X / BSD / Linux (note the utilities like find(1) may behave a bit differently across unix-like systems).<p>I use the Makefile w/ entr(1) in development on my projects like tmuxp at <a href="https://github.com/tony/tmuxp/blob/master/Makefile" rel="nofollow">https://github.com/tony/tmuxp/blob/master/Makefile</a>. tmuxp is BSD-licensed so you're free to work off that if you'd like to try it on your own project.
<p><pre><code> ls -d * | entr make
</code></pre>
Just a nit: this seems to be imperfect for filenames containing new lines (I know, I know). An xargs like -0, --null option could make it more robust. Then the equivalent of the above command would be something like:<p><pre><code> find . -maxdepth 1 -name '[!.]*' -print0 | entr -0 make
</code></pre>
Edit: Seems like -print0 is not POSIX compliant. Is there any safe way to pass a list of paths using the shell in a fully POSIX compliant way?
What a coincidence! I tested it yesterday. Worked like a charm. Thanks!<p>One note: the browser reloading script was not installed on debian, so I downloaded it. It was not clear from the documentation if that was the intention.
A similar tool written in Rust is watchexec.<p><a href="https://github.com/mattgreen/watchexec" rel="nofollow">https://github.com/mattgreen/watchexec</a>
Ruby developers have been using Guard for a long time now.<p><a href="https://github.com/guard/guard" rel="nofollow">https://github.com/guard/guard</a>
I use entr all the time. I usually do something like piping go files to entry to run a script to build and run my app or tests.<p>Much simpler than most tools I've seen like it.
> It is not uncommon for modern web frameworks to continuously hunt for file system changes and auto-reloads when run in single threaded or standalone mode. This functionality is superfluous if the application can respond to signals.<p>This is true if all that happens is a page reload, butamy frameworks are able to patch code or styles into the running page without a reload. This requires more than a signal handler.
Many years ago I did a little utility I called autobuild[0] to do similar things. It has osx and windows support, but never got around doing linux support. I don't think inotify has an easy way of doing recursive filesystem notifications, having to manage the hierarchy and their notifiers, so it lapsed when I didn't need it at the time.<p>It felt like this kind of tool would/should be one of those standard command line tools always available, or the at least of those standard things everyone knows to install, like silversearcher/ripgrep etc.<p>[0] <a href="https://github.com/scoopr/autobuild" rel="nofollow">https://github.com/scoopr/autobuild</a>
this is one of those problems I've needed to solve for forever, but which i've never explicitly looked up a clean solution for. I can immediately think of 3 instances in the past week where this would have been perfect.
A long time entr user, I recently switch to modd for flexible almost makefile like configurability, and watching/ignoring of multiple patterns to name a few convenient feature.<p><a href="https://github.com/cortesi/modd" rel="nofollow">https://github.com/cortesi/modd</a>
I wrote a dead-simple version of this (that uses polling and doesn't give you filters for files) in python and called it `jonsnow` and threw it on pypi. I understand this is an insanely useful utility, but it's interesting that everyone seems to spin their own :)
awesome.<p>What would be really great is a fuse DAG.<p>Some paths should run programs on write, others on read.<p>The filesystem is <i>already</i> the lock provider for a lot of programs; we should be using it as the event processor.<p>This is inherently polyglot -- every programming language in common use has FS utils.
For node: <a href="https://github.com/kimmobrunfeldt/chokidar-cli" rel="nofollow">https://github.com/kimmobrunfeldt/chokidar-cli</a>