Watch Files With fswatch

Monitor directories and trigger scripts from a stream of change events.

macOSwatchFilesautomationLow risk
Run fswatch -o src | xargs -n1 -I{} make to rebuild when files under src change.

01Command

Command
$ fswatch -o src | xargs -n1 -I{} make

02What it does

fswatch emits one line per change event, optionally collapsed with -o, so it composes naturally with xargs and shell scripts. It supports include/exclude filters with -i and -e and can monitor several directories at once.

03Risk

RiskLow risk
CompatibilitymacOS with Homebrew installed
!Warning: Recursive watches on huge trees can exhaust file descriptors or miss events on some platforms; narrow the paths.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • Homebrew formula: fswatch
    Homebrew · vendor-doc · 2026-09-20
    Evidence: Packages fswatch, a cross-platform file change monitor that emits changed paths.

Last verified: 2026-09-22 · Category: Developer

06Related solutions