entr(1)

Run arbitrary commands when files change

project page

kqueue(2) on BSD and Mac requires one file descriptor for each file and directory under watch. This poses a problem when watching a large code base since the default limit imposed by some operating systems is not very high.

Use the following instructions to set a default that is more reasonable for your use case. For simplicity, we assume that a reboot after changing configuration.

BSD

Modify /etc/login.conf

staff:\
:openfiles-max=16384:\
:openfiles-cur=4096:\

MacOS

On 10.13 and later maxfiles is unlimited, but this is not reported properly by the operating system. entr 5.4 or later always sets the file limit to 2^16 in order to take advantage of this file limit.

On oder releases the file open limit can be raised by installing a new property list file

cd /Library/LaunchDaemons
sudo curl -sO https://eradman.com/entrproject/etc/limit.maxfiles.plist

Verify the content of this file using

shasum limit.maxfiles.plist
5c932adc5412d1da93ac68c930085d2b2e9c27df  limit.maxfiles.plist

Linux

The maximum number of inotify watches may be set by setting the max_user_watches sysctl

cat /proc/sys/fs/inotify/max_user_watches

Make changes permanent by adding a file to /etc/sysctl.d/.