entr — Run Arbitrary Commands When Files Change
entr is a tiny, dependency-free event notify-based tool for running commands when any file in a list changes, perfect for live-reload workflows with tests, linters, and builds.
What it is
entr is a small, dependency-free Unix utility that runs arbitrary commands when files in a given list change. It uses kernel-level file notification APIs (kqueue on macOS/BSD, inotify on Linux) for efficient, low-overhead monitoring.
It targets developers who want live-reload workflows for running tests, linters, formatters, or build commands without installing heavy file-watching frameworks. Feed it a file list via stdin, give it a command, and it reacts instantly.
How it saves time or tokens
Manual rebuild cycles (edit, switch to terminal, type command, read output, switch back) add up fast. entr eliminates the 'switch and type' step entirely. Every save triggers the command automatically. For test-driven development, this means seeing test results within a second of saving a file.
How to use
- Install entr via your package manager:
brew install entr(macOS),apt install entr(Debian/Ubuntu). - Pipe a list of files to entr and specify the command to run.
- Edit any watched file. entr detects the change and re-runs the command.
Example
# Re-run tests on any Python file change
find . -name '*.py' | entr -c python -m pytest
# Rebuild a Go binary on save
ls *.go | entr -r go run main.go
# Run a linter when JS files change
find src/ -name '*.js' | entr npx eslint src/
# Restart a server (-r flag) on changes
find . -name '*.rb' | entr -r ruby server.rb
Related on TokRepo
- Automation tools — More tools for automating developer workflows
- DevOps tools — Build, test, and deploy automation
Common pitfalls
- entr watches the specific files piped to it, not directories. If you create a new file, you need to restart entr (or use the
-dflag to detect new files in directories). - On Linux, hitting the inotify watch limit causes silent failures. Increase
fs.inotify.max_user_watchesin sysctl if you watch large file trees. - The
-cflag clears the terminal before each run, which is helpful for readability but can hide earlier error messages if you scroll up.
Frequently Asked Questions
nodemon is Node.js-specific and watches directories by default. watchexec is a Rust-based alternative with directory watching and glob patterns. entr follows the Unix philosophy: it takes a file list on stdin and runs a command. It is simpler, smaller, and language-agnostic.
By default, entr only watches files explicitly listed on stdin. Use the -d flag to make entr exit when a new file is added to a watched directory, then wrap it in a loop that restarts entr with the updated file list.
entr is designed for Unix-like systems (Linux, macOS, FreeBSD). On Windows, you can use it through WSL (Windows Subsystem for Linux). Native Windows alternatives include watchexec or PowerShell file watchers.
By default, entr waits for the command to finish before reacting to new changes. With the -r flag, entr kills the running process and restarts it, which is useful for long-running servers.
entr can handle thousands of files, but you may hit OS-level watch limits. On Linux, increase the inotify watch limit. On macOS, kqueue handles large file lists well. For very large repos, consider filtering the file list to only include files relevant to your current task.
Citations (3)
- entr GitHub Repository— entr runs commands when files change using kernel event APIs
- Linux man pages— inotify file watching API on Linux
- Apple Developer Documentation— kqueue event notification on BSD/macOS
Related on TokRepo
Discussion
Related Assets
NAPI-RS — Build Node.js Native Addons in Rust
Write high-performance Node.js native modules in Rust with automatic TypeScript type generation and cross-platform prebuilt binaries.
Mamba — Fast Cross-Platform Package Manager
A drop-in conda replacement written in C++ that resolves environments in seconds instead of minutes.
Plasmo — The Browser Extension Framework
Build, test, and publish browser extensions for Chrome, Firefox, and Edge using React or Vue with hot-reload and automatic manifest generation.