Created
May 21, 2015 01:39
-
-
Save cmbankester/48a44fa55b2db85827ef to your computer and use it in GitHub Desktop.
Filter fswatch events by type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage: | |
# file-event-watch command-to-run path1 [path2, ...] | |
# TODO: Add fswatch event option to enable/disable different event types | |
cmd=$1 | |
shift | |
files=$@ | |
$cmd && fswatch -0 -x -r $files | { | |
while read -d "" event; do | |
case $event in | |
*Created|*Updated|*Removed|*Renamed|*OwnerModified|*AttributeModified|*MovedFrom|*MovedTo ) | |
# https://github.com/emcrisostomo/fswatch/blob/master/src/fswatch.cpp | |
# If it's one of these events, run cmd, else ignore it | |
$cmd | |
;; | |
esac | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The updated
fswatch.cpp
URL is https://github.com/emcrisostomo/fswatch/blob/master/fswatch/src/fswatch.cpp