explaingit

eradman/entr

5,571CAudience · developerComplexity · 1/5Setup · easy

TLDR

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.

Mindmap

mindmap
  root((repo))
    What it does
      Watch files
      Run on change
    How it works
      kqueue on macOS
      inotify on Linux
      No polling
    Flags
      -r restart process
      -c clear screen
      -d watch new files
      -z exit on stop
    Use cases
      Auto rebuild
      Server reload
      Test runner
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Auto-rebuild a project every time you save a source file without pressing a key

USE CASE 2

Reload a web server automatically whenever a JavaScript or config file changes

USE CASE 3

Re-run a test suite instantly each time you edit a test file

USE CASE 4

Watch SQL scripts and re-run a database query every time one is saved

Tech stack

C

Getting it running

Difficulty · easy Time to first run · 5min

Docker for Mac and WSL users need to set a specific environment variable to work around incomplete inotify support.

License terms are not specified in the explanation.

In plain English

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.

Copy-paste prompts

Prompt 1
Show me the entr command to watch all .js files in a src/ directory and restart a Node.js server each time one changes
Prompt 2
How do I use entr with the -r flag to restart a long-running process on file change instead of running a one-shot command?
Prompt 3
Write a shell one-liner using find and entr that watches all Python files in a project and re-runs pytest on any change
Prompt 4
How do I use entr's -d flag to detect when new files are added to a directory and start watching them automatically?
Prompt 5
What environment variable do I need to set to make entr work inside Docker for Mac or Windows Subsystem for Linux?
Open on GitHub → Explain another repo

← eradman on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.