-
Notifications
You must be signed in to change notification settings - Fork 0
/
zatch.1
87 lines (87 loc) · 2.68 KB
/
zatch.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
.\" Copyright (c) 2017, 2018, 2019 Tim Kuijsten
.\"
.\" Permission to use, copy, modify, and/or distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: February 22 2019 $
.Dt ZATCH 1
.Os
.Sh NAME
.Nm zatch
.Nd efficiently watch directory changes on macOS
.Sh SYNOPSIS
.Nm
.Op Fl Vhpqsv
.Ar dir ...
.Sh DESCRIPTION
.Nm
efficiently watches directory changes on macOS.
It does this by coalescing all changes in a directory that happen within 30 ms
and echo a line on stdout to indicate that one or more things changed in that
directory or any of it's subdirectories.
A trailing slash on the echoed directory names is ensured.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl V
Print version and exit.
.It Fl h
Print usage and exit.
.It Fl p
Preflight - echo the name of each dir on the command line once before starting
to monitor.
.It Fl q
Be less verbose.
Can be used multiple times.
.It Fl s
Show subdirs to narrow down where a change occurred.
Since all changes within 30 ms are coalesced, some changes might have occurred
in a subdirectory of the one that is echoed.
.It Fl v
Be more verbose.
Can be used multiple times.
.It Ar dir
One or more directories to watch.
A trailing slash is appended if not already specified before echoing
.Ar dir
to
.Dv stdout .
.El
.Sh EXIT STATUS
.Ex -std
.Sh EXAMPLES
Run rsync anytime a file in
.Em foo
or
.Em bar
or any of it's subdirectories changes:
.Bd -literal -offset indent
zatch foo bar | while read _path; do rsync -az "$_path" example.com: ; done
.Ed
.Pp
Show a macOS notification with the name of the subdirectory that contains
changes, but filter out any component named
.Em xar :
.Bd -literal -offset indent
zatch -s foo bar | fgrep --line-buffered -v '/xar/' | while read _path
do osascript -e "display notification \\"$_path\\""
done
.Ed
.Pp
Initially start Node.js, and restart whenever a file changes in the current
working dir or any of it's subdirectories:
.Bd -literal -offset indent
node server.js & zatch . | while read -r p; do echo "$p" && kill $! ; node server.js & done
.Ed
.Sh AUTHORS
.An -nosplit
.An Tim Kuijsten