From 44c201c7a727406c09289edf07e7236ab0cb70db Mon Sep 17 00:00:00 2001 From: ptzz Date: Wed, 23 May 2018 04:33:25 +0200 Subject: [PATCH] fswatch: Fix broken commands + simplifications Without the `-n 1` argument to `xargs`, fswatch will will not trigger on events. --- pages/common/fswatch.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pages/common/fswatch.md b/pages/common/fswatch.md index 0a39e736d..49140353e 100644 --- a/pages/common/fswatch.md +++ b/pages/common/fswatch.md @@ -4,16 +4,16 @@ - Run a bash command on file creation, update or deletion: -`fswatch -0 {{path/to/file}} | xargs -0 {{bash_command}}` +`fswatch {{path/to/file}} | xargs -n 1 {{bash_command}}` - Watch one or more files and/or directories: -`fswatch -0 {{path/to/file}} {{path/to/directory}} {{path/to/another_directory/**/*.js}} | xargs -0 {{bash_command}}` +`fswatch {{path/to/file}} {{path/to/directory}} {{path/to/another_directory/**/*.js}} | xargs -n 1 {{bash_command}}` -- Use `{}` in your bash command as a placeholder for the absolute path to the changed file: +- Print the absolute paths of the changed files: -`fswatch -0 {{path/to/directory}} | xargs -0 -I {} {{bash_command}}` +`fswatch {{path/to/directory}} | xargs -n 1 -I {} echo {}` - Filter by event type, eg. Updated, Deleted or Created: -`fswatch -0 --event {{Updated}} {{path/to/directory}} | xargs -0 {{bash_command}}` +`fswatch --event {{Updated}} {{path/to/directory}} | xargs -n 1 {{bash_command}}`