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.
Installation agent prête
Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.
npx -y tokrepo@latest install bd0e9cda-389d-11f1-9bc6-00163e2b0d79 --target codexÀ exécuter après confirmation du plan en dry-run.
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.
Questions fréquentes
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.
Sources citées (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
En lien sur TokRepo
Fil de discussion
Actifs similaires
watchexec — Run Commands When Files Change, with Smart Defaults
watchexec watches a directory tree and runs a command when anything changes. Cross-platform, respects .gitignore, debounces, restarts long-running processes — the swiss-army knife of file-watching.
q — Run SQL Directly on CSV, TSV, and Log Files
q (harelba/q) runs full SQLite-compatible SQL queries against CSVs, TSVs, and any delimited text file on disk — turning ad-hoc log digging into a one-line SQL statement.
Valtio — Proxy-Based State Management for React
Valtio makes React state management simple by wrapping plain JavaScript objects in a proxy, so components automatically re-render when the properties they read change — no reducers, actions, or boilerplate required.
act — Run GitHub Actions Locally
act lets you run GitHub Actions workflows on your local machine. Test and debug your CI/CD pipelines without pushing to GitHub, using Docker containers to simulate the GitHub Actions runner environment.