1ENTR(1) BSD General Commands Manual ENTR(1)
2
4 entr — run arbitrary commands when files change
5
7 entr [-acdprs] utility [argument /_ ...]
8
10 A list of files provided on the standard input and the utility is exe‐
11 cuted using the supplied arguments if any of them change. entr waits for
12 the child process to finish before responding to subsequent file system
13 events. A TTY is also opened before entering the watch loop in order to
14 support interactive utilities.
15
16 The arguments are as follows:
17
18 -a Respond to all events which occur while the utility is running.
19 Without this option entr consolidates events in order to avoid
20 looping. This option has no effect in conjunction with the -r
21 flag.
22
23 -c Execute /usr/bin/clear before invoking the utility specified on
24 the command line.
25
26 -d Track the directories of regular files provided as input and exit
27 if a new file is added. This option also enables directories to
28 be specified explicitly. Files with names beginning with ‘.’ are
29 ignored.
30
31 -n Run in non-interactive mode. In this mode entr does not attempt
32 to read from the TTY or change its properties.
33
34 -p Postpone the first execution of the utility until a file is modi‐
35 fied.
36
37 -r Reload a persistent child process. As with the standard mode of
38 operation, a utility which terminates is not executed again until
39 a file system or keyboard event is processed. SIGTERM is used to
40 terminate the utility before it is restarted. A process group is
41 created to prevent shell scripts from masking signals. entr
42 waits for the utility to exit to ensure that resources such as
43 sockets have been closed. Control of the TTY is not transferred
44 the child process.
45
46 -s Evaluate the first argument using the interpreter specified by
47 the SHELL environment variable. When this flag is set, the name
48 of the shell and exit code is printed after each invocation.
49
50 The first argument named /_ is replaced with the absolute path of the
51 first file to trigger an event. If the restart option is used the first
52 file under watch is treated as the default.
53
55 entr listens for keyboard input and responds to the following commands:
56
57 SPACE Execute the utility immediately. If the ‘-r’ option is set
58 this will terminate and restart the child process as if a
59 file change event had occurred.
60
61 q Quit; equivalent pressing Ctrl-C.
62
64 If PAGER is undefined, entr will assign /bin/cat to prevent interactive
65 utilities from waiting for keyboard input if output does not fit on the
66 screen.
67
68 If SHELL is undefined, entr will use /bin/sh.
69
71 The entr utility exits with one of the following values:
72
73 0 SIGINT or SIGTERM was received
74 1 No regular files were provided as input or an error
75 occurred
76 2 A file was added to a directory and the directory watch
77 option was specified
78
80 Rebuild a project if source files change, limiting output to the first 20
81 lines:
82
83 $ find src/ | entr -s 'make | head -n 20'
84
85 Launch and auto-reload a node.js server:
86
87 $ ls *.js | entr -r node app.js
88
89 Launch and auto-reload a node.js server as a background task:
90
91 $ (ls *.js | entr -r node app.js &)
92
93 Clear the screen and run a query after the SQL script is updated:
94
95 $ echo my.sql | entr -p psql -f /_
96
97 Rebuild project if a source file is modified or added to the src/ direc‐
98 tory:
99
100 $ while true; do ls src/*.rb | entr -d make; done
101
102BSD March 28, 2019 BSD