fswatch
is a simple command-line tool for watching filesystem changes and running a command
in response to them.
Currently the only way to install fswatch
is the golang
toolkit:
$ go install github.com/tasdomas/fswatch
fswatch [ --events create,write,remove,rename,chmod ] [ --command <command> ]
By default fswatch
will listen for all events on a specified path (a directory or a file).
The events include:
create
: creating a file or subdirectorywrite
: writing to a fileremove
: removing of a file or subdirectoryrename
: renaming a file or subdirectorychmod
: changing access permissions
Watching a directory will watch for changes to files and subdirectories directly inside it but will not watch for changes inside subdirectories.
The change event's path and comma-separated list of event names can be passed to the command using
{Path}
and {Events}
placeholders:
fswatch --command 'echo {Path} {Events}' ./