6 ms·
That's literally in the article; `entr -d`. The manpage also has an entry. http://eradman.com/entrproject/entr.1.html#d http://eradman.com/entrproject/entr.1.ht
by akx 6y ago
That's literally in the article; `entr -d`. The manpage also has an entry. http://eradman.com/entrproject/entr.1.html#d http://eradman.com/entrproject/entr.1.html#d
- inshadows 6y agoTerminal 1: mkdir /tmp/project cd /tmp/project touch file{1,2} ls | entr -d echo "a change" Terminal 2: rm file2 Terminal 1: entr: cannot open 'file2': No child processes Regarding `-d`: > Track the directories of regular files provided as input and exit if a new file is added. This option also enables directories to be specified explicitly. Files with names beginning with ‘.’ are ignored. So first, it doesn't track NEW directories, and second, it exits if new file is added. Exactly how is this useful? EDIT: All I want from filesystem watcher is to track files by pattern and just re-run the command, however complex that may be to implement via OS interfaces. When I'm working on a Python project that has packages (directories), I may also refactor (rename files), and this simplistic behavior does not catch that.
- coder543 6y ago> All I want from filesystem watcher is to track files by pattern and just re-run the command, however complex that may be to implement via OS interfaces. I've had good luck with modd: https://github.com/cortesi/modd/ https://github.com/cortesi/modd/ I just tested exactly what you described, did not see any errors, and it ran my commands exactly the way I wanted.
- natrys 6y agoI can attest to modd too, it uses a (per project) configuration file to define include/exclude (recursive) globs, along with respective blocks of commands. I would also like to extol virtues of its sister project devd[0] from same author which makes web development palatable to me. It's a little websocker server that injects a tiny script into HTML to reload the page in browser once modd detects file change, rebuilds front-end and sends devd a SIGHUP. [0] https://github.com/cortesi/devd https://github.com/cortesi/devd
- jdxcode 6y agoI think the interface for `-d` is clunky, but here is the way it is intended to be used: $ while true; do > ls -d src/*.py | entr -d ./setup.py > done that way when a file/dir is added/removed it restarts
- Groxx 6y agoThis is in fact the documented recommendation, from the manpage: Rebuild project if a source file is modified or added to the src/ directory: $ while true; do ls src/*.rb | entr -d make; done
- Adverblessly 6y ago> All I want from filesystem watcher is to track files by pattern and just re-run the command, however complex that may be to implement via OS interfaces. I assume I'm misunderstanding something, so this is probably a naive question and maybe you can explain further, but if that is all you need why not just write it yourself? It sounds like an <1 hour project to write something cross-platform in Qt that monitors the filesystem recursively with QFileSystemWatcher https://doc.qt.io/qt-5/qfilesystemwatcher.html https://doc.qt.io/qt-5/qfilesystemwatcher.html checks for the configured regexen and runs the configured command.
- hobo_mark 6y agoWhat's wrong with watchman? Seems to be made for that very use case. https://facebook.github.io/watchman/ https://facebook.github.io/watchman/
- klodolph 6y agoI have implemented stuff like this. It is not even remotely a <1 hour project. Not if you want it to work reasonably well and not be broken all the time. It’s a full workday for someone who already understands the problem. There are a number of cases you often want to handle: - Multiple files may change in quick succession, for example, if you hit “save all” in an editor. You might want to delay triggers to see if more events arrive. - You will sometimes see incomplete / corrupted versions of files, because you ran a command while another program was writing the file. The other program probably should atomically rewrite the file, but you’re stuck fixing the problem. The user doesn’t want to see errors from this and you generally want to rerun the command. - You need to execute commands in the correct order. - A command may change state from being queued&ready to having outdated inputs. If it’s just one command, sure, you could probably do it in an hour. But if there’s more than one command (usually the case!) then it gets far more complicated. Just looking at the last time I implemented something like this--it was watchman + about 500 lines of code figuring out which actions to run and when. And that’s not even with any parallel execution.