ScriptsApr 15, 2026·2 min read

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.

TL;DR
entr watches a list of files and runs any command you specify when changes are detected, enabling instant feedback loops.
§01

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.

§02

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.

§03

How to use

  1. Install entr via your package manager: brew install entr (macOS), apt install entr (Debian/Ubuntu).
  2. Pipe a list of files to entr and specify the command to run.
  3. Edit any watched file. entr detects the change and re-runs the command.
§04

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
§05

Related on TokRepo

§06

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 -d flag to detect new files in directories).
  • On Linux, hitting the inotify watch limit causes silent failures. Increase fs.inotify.max_user_watches in sysctl if you watch large file trees.
  • The -c flag clears the terminal before each run, which is helpful for readability but can hide earlier error messages if you scroll up.

Frequently Asked Questions

How does entr compare to nodemon or watchexec?+

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.

Can entr watch for new files being created?+

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.

Does entr work on Windows?+

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.

What happens if the command is still running when a file changes?+

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.

Is entr suitable for large monorepos with thousands of files?+

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)

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets