6 ms·
Entr: Rerun your build when files change
- leephillips 4y agoI use entr for all my file-watching needs, if I need a roll-my-own solution. This article is a good introduction to the main ways to use it. If you use Vim, however, its defaults can interfere with auto-build setups that depend on file watching: https://lee-phillips.org/badvim/ https://lee-phillips.org/badvim/
- melissalobos 4y agoAnother solution is just to use inotify-tools and inotify-watch and wrap that in a while true with your commands after. But I like this solution much more.
- stephen_cagle 4y agoI use `entr` all the time for feedback on testing and development. Have you found a way to get it to handle "new" files. It is very good at watching a group of files, but my memory of it is that it barfs when you add/remove files? > ls *.clj | entr -rcs './problem01.clj < input01.txt' The problem is that ls only returns the list of files that existed at the time it was run...
- leephillips 4y agoThere is an example of how to do that in the article, using `entr -d`.
- stephen_cagle 4y agoNot a huge deal, but this "exits" when you have a change to a directory. So you end up having to put the whole thing in a while loop. But then you can't capture SIGINT and now you have to kill the process. So you need to write something that can capture that and conditionally break the loop if it is such... entr is focused on doing what it does well, and I don't have a solution here. Just feels like there should be something to handle that use case.
- junon 4y agoUse -d and a while loop. Keep in mind, this is a limitation of filesystem watchers, not entr specifically. It'd would have to do some juggling whenever a file was added.
- karmakaze 4y agoI've also used Air[0] (and before that Gin) which says is for Go programs but lets you configure the commands and filters to work with any language/build. [0] https://github.com/cosmtrek/air https://github.com/cosmtrek/air
- deleted 4y ago[deleted]
- cjlm 4y agoI’ve been a happy user of watchexec[0] for the past few months but Entr seems cool. https://github.com/watchexec/watchexec https://github.com/watchexec/watchexec
- zeepzeep 4y agoI use https://github.com/eaburns/Watch https://github.com/eaburns/Watch
- david2ndaccount 4y agoI wrote my own file watching utility for macos: https://github.com/drpriver/macwatch https://github.com/drpriver/macwatch does a similar thing.
- jasfi 4y agoI found a similar utility for Windows: https://github.com/TechieGuy12/FileWatcher https://github.com/TechieGuy12/FileWatcher
- ghoward 4y agoThis is a cool utility, but I feel that its existence is entirely predicated on not having a proper build system. A proper build system should be able to be integrated with your editor or IDE, and whenever a save happens, a plugin for your editor/IDE, or a filesystem scan by the build system server, should activate a "quick build" using the list of changed files. Of course, entr fills the niche where you want something to happen but don't want to go to the trouble of setting up a build system, so it had that going for it as well. Disclaimer: I'm building such a build system. And now I wonder if I can design it such that it fulfills all of the roles entr does...
- junon 4y agoDisagree. I write build systems for fun and Entr is part of my daily toolkit anyway. You don't use a build system for everything, and filesystem watchers are glitchy at best. To create a watch on 30k files is a huge strain and is prone to fail. Entr is great because it does one thing super duper well. Been using it for years almost daily and never have any issues with it.
- Proven 4y ago