DEV Community

Joel Jucá
Joel Jucá

Posted on

2 2 2 2 2

Meet entr, the standalone file watcher

I like to write about tools in my toolbelt I love, and entr is one of these preferred tools I enjoy using a lot.

Today I'm talking about entr – the Standalone File Watcher.

What's entr?

entr ("Event Notify Test Runner"; GitHub), is a command-line tool written by Eric Radman that allows running arbitrary commands whenever files change.

It's not tied to any programming language, framework, platform, OS, etc. – it's a real standalone tool, pretty useful in a variety of scenarios.

Usage

First, use find to craft a command that lists the files you're working with:

find . -name '*.md'
Enter fullscreen mode Exit fullscreen mode

Then, just pipe it to entr with a command to be run whenever files change:

find . -name '*.md' | entr echo "Markdown files changed!"
Enter fullscreen mode Exit fullscreen mode

entr has some very interesting options, like the ability to clear the screen before running the given command (so you get a cleaner output). To get a full list of options, check its man page with:

man entr
Enter fullscreen mode Exit fullscreen mode

Continuously testing with entr

As you might have guessed, one of the main use cases for entr is to rerun tests whenever files change. I'm an Elixir engineer, and I use entr to run mix test continuously whenever I save an Elixir file.

This is the snippet I use to continuously test my Elixir library SwissSchema while I'm working on it:

find -E lib test -regex '.*exs?$' | entr -c mix test
Enter fullscreen mode Exit fullscreen mode

A snippet I obviously can't recall from the top of my head every time I need to run it. Luckily, this project has a Makefile with a task for it:

test.watch:
    find -E lib test -regex .*exs?$ | entr -c mix test
Enter fullscreen mode Exit fullscreen mode

💡 I wrote two articles here on DEV about Makefiles, one covering their overall utility and usage, and another with my Makefile setup for Elixir projects:

That's it. There's not much to learn, entr is really this awesome!

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

While many AI coding tools operate as simple command-response systems, Qodo Gen 1.0 represents the next generation: autonomous, multi-step problem-solving agents that work alongside you.

Read full post →

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay