ENTR: The Modern File Watcher for Instant Feedback

A magnifying glass over a computer screen.

The Iteration Loop

The core speed of a developer is determined by the “Inner Loop”: the time it takes to change a line of code, run the program, and see the result. If this process requires you to manually switch to the terminal, hit Ctrl+C, and run a command daily, you are leaking productivity.

You need a file watcher. And while every language has its own (like nodemon for Node.js or guard for Ruby), the ultimate, language-agnostic tool for the terminal is ENTR.

1. What is ENTR? (The Unix Philosophy)

entr (Event Notify Test Runner) is a utility designed to run arbitrary commands when files change. It follows the Unix Philosophy: do one thing, and do it well.

Unlike complex build tools, entr doesn’t have a giant JSON config file. It doesn’t even have a built-in search engine. Instead, it takes a list of files from stdin and a command as an argument.

The Basic Pattern:

ls *.py | entr python my_script.py

This takes the output of ls and feeds it into entr. Now, every time a Python file is saved, the script runs.

2. Why it beats the competition

Feature ENTR Nodemon / Watchman
Ecosystem Language agnostic Usually language-specific
Footprint Tiny C binary Massive Node/Rust dependency
Logic Piped from find or git Built-in recursive scanner
Reactivity Uses kernel kqueue or inotify Often uses polling (slower)

3. Power Techniques for the Professional Terminal

Use git ls-files for Precision

Don’t watch your entire node_modules or .git folder—it will crash the watcher. Instead, use Git to tell entr exactly which files matter:

git ls-files | entr -c go run main.go

The -c flag tells entr to clear the screen before each run, so you only see the latest logs.

Auto-Restarting Servers (-r)

If you are building a web server, you don’t just want to run a script; you want to kill the old process and start a new one. The -r flag handles this signal management automatically:

ls *.go | entr -r go run main.go

Running Tests in the Background

Keep a small terminal window open to the side. Pipe your test files into it. Every time you save a function, you’ll see the “10/10 tests passed” green light.

find src -name "*.test.js" | entr npm test

4. Advanced: Combining with git and tmux

If you are using Tmux, you can combine entr with a split-pane layout to build a custom IDE-like experience. For example, have your code on the left and a dedicated entr watcher on the right that automatically rebuilds your documentation or re-renders your Markdown preview.

Conclusion

entr is a tool that respects your time. It is small, fast, and does exactly what you expect. By automating the “re-run” part of your development day, you free your brain to focus on the “coding” part. Every second saved is a second added back to your creative flow.


References & Further Reading

Last updated on