Couple of file watchers
So I often reach for the Python based watchfiles written by Samuel Colvin, when I need to watch a directory for changes. Because it’s a Python library you can customize it however you need.
Today I learned about a couple other versions of this class of tool.
watchexec
This seems to be the most full featured out of the box. It’s written in Rust and some nice ergnomic feature like:
watchexec -e js,css,html npm run build To watch only JS, CSS, and HTMl files by extension and then run the command you pass.
It ignores any files in your .gitignore or .ignore files, can clear the screen between
refreshes, is cross platform and supports glob patterns.
You can learn more in the watchexec Github repo
entr
Not sure how I haven’t heard of this older Unix utility until today, but it’s worth a mention.
It works by piping a list of files to it and then running the command you specify, so useful if you want to chain a few things together for sure.
ls | entr -s 'make && make test' They specifically mention using ack or ag to list the files as it supports
listing files by type like the extension option I showed for watchexec.
Add both of these, or all three if you haven’t heard of watchfiles to your toolkit to make
your life a little easier!