Event Notify Test Runner (entr) - Project Overview
The Event Notify Test Runner, commonly referred to as entr
, is a handy utility designed to execute specific commands whenever files in a specified directory undergo changes. This tool significantly enhances productivity by allowing for rapid feedback directly from the command line. Unlike traditional methods that rely on regular polling for file changes, entr
employs more efficient mechanisms such as kqueue(2)
on BSD systems and inotify(7)
on Linux systems to track modifications in real-time.
Source Installation
For users operating on BSD, Mac OS, or Linux systems, installing entr
from the source is an easy process. Here’s a simple breakdown of the installation steps:
- Run the command
./configure
to prepare the build system. - Execute
make test
to run any tests and ensure that everything is set up correctly. - Finally, use
make install
to install the utility on your system.
If you wish to explore various build options, simply run ./configure -h
.
Compatibility with Docker and WSL
While entr
normally functions smoothly, there are known limitations when it's used in environments like the Windows Subsystem for Linux (WSL) and Docker for Mac due to incomplete support for inotify
. Fortunately, by setting the environment variable ENTR_INOTIFY_WORKAROUND
, users can enable entr
to work properly in these specific setups.
Features for Linux Users
Linux users have an additional feature that allows entr
to monitor symlinks for changes. To utilize this capability, they need to set the environment variable ENTR_INOTIFY_SYMLINK
.
Examples of Usage
entr
is particularly popular for several practical applications, which are illustrated in its manual pages as follows:
-
Rebuilding Projects: If you need to rebuild a project each time a source file changes, you can run a command like:
$ find src/ | entr -s 'make | head -n 20'
This limits the output to the first 20 lines.
-
Auto-reloading a Node.js Server: Automatically reload a Node.js server when any
.js
file changes using:$ ls *.js | entr -r node app.js
-
Running SQL Queries: Clear the terminal screen and execute a SQL query when a script is updated:
$ echo my.sql | entr -cp psql -f /_
-
Monitoring Additions in a Directory: Rebuild a project when a new file is added or an existing file is modified in the
src/
directory:$ while sleep 0.1; do ls src/*.rb | entr -d make; done
-
Web Server Auto-reloading: Set up a web server to reload automatically, or terminate if it exits, with:
$ ls * | entr -rz ./httpd
Staying Updated
To keep users informed about new releases, entr
provides an Atom feed. For those interested in the project's release history, details are available in the NEWS
file.
Overall, entr
is a valuable tool for developers who require instant feedback from their projects, helping streamline their workflow effectively.