entr

Productivity boost with entr

entr - run arbitrary commands when files change

History

entr was create by Eric Radman to run all his unit test when a source file was changed. I started using this late 2016 and I got an enourmous productivity boost out of it.

FAQ

What is it?

A file watcher, that can trigger actions

How cool is it?

Reasonable.

Competitors?

libinotify, watchman, bubblegum, xdotool, ..

When to use it?

When you want to automate some (development) processes

Is it dead?

Nope, but it is rather complete.

Where is it?

http://entrproject.org/

How to use it

Download/install

sudo apt-get install entr
entr --help
release: 3.6
usage: entr [-cdpr] utility [args, [/_], ...] < filenames

That does not tell us much but the man page and the official site is very extensive.

Basically entr takes a list of files or directories as input and watches them. If there is a change it runs the args.

Practial guidance

Normal mode

Following the manual, the '-c' flag, clears the console.

The combination i3, terminator, and bash history browsing may sometimes mess up some characters. I have not yet pinpointed the exact cause.

find ls /etc/postgresql/9.6/main/*.conf |entr -c service postgresql restart

Daemon mode

With the -r flag, the arg[0] process is killed befor the args are restarted.

The static website generator gutenberg, has a development mode (serve) that watches the templates, static and content directories. Unfortunately, the theme directory and the main configfile are not watched. For theme developers, entr is a realy nice tool.

find ./theme/materialize config.toml -type f| entr -r /opt/gutenberg/target/release/gutenberg serve

Further reading:

We only tipped the top of the iceberg here. There are much more details in the man page and the official site.