entr
Run arbitrary commands when files change
entr is a tiny Unix command-line tool that watches a list of files and runs a command automatically whenever any of them changes. It uses the kernel's own file-watching APIs so it responds instantly without polling.
entr is a small command-line utility written in C that watches files for changes and runs a command whenever a change is detected. The idea is simple: you pipe a list of file paths into entr, tell it what command to run, and it watches those files. When any of them changes, it runs your command automatically. This creates a tight feedback loop without you having to press a key or switch windows.
Under the hood, entr uses the operating system's built-in file-watching mechanisms: kqueue on BSD and macOS, and inotify on Linux. Using these kernel features rather than repeatedly checking file timestamps makes entr lightweight and very quick to respond.
Common uses shown in the documentation include rebuilding a project when source files are modified, auto-reloading a web server whenever JavaScript files change, or re-running a database query after a SQL script is updated. A few flags extend the behavior: -r restarts a long-running process each time a change is detected, -c clears the terminal screen before each run, -d watches for newly added files in addition to existing ones, and -z exits if the launched process terminates on its own.
The tool runs on BSD, macOS, and Linux. Installation is a short configure-and-make process from source. Users on Docker for Mac or Windows Subsystem for Linux may encounter incomplete inotify support and need to set a specific environment variable to work around it.
The project is intentionally narrow in scope. The README is short and there is no configuration file system. entr does one thing: run a command when files change, using the kernel's own notification system so nothing is wasted on polling.
Where it fits
- Auto-rebuild a project every time you save a source file without pressing a key
- Reload a web server automatically whenever a JavaScript or config file changes
- Re-run a test suite instantly each time you edit a test file
- Watch SQL scripts and re-run a database query every time one is saved