Skip to content

Instantly share code, notes, and snippets.

@pfeilbr
Last active January 29, 2019 16:26
Show Gist options
  • Save pfeilbr/715f8da53450726c4c663eac83e4c096 to your computer and use it in GitHub Desktop.
Save pfeilbr/715f8da53450726c4c663eac83e4c096 to your computer and use it in GitHub Desktop.
example of getting file change details along with a batch marker. fswatch
# example of getting file change details along with a batch marker
# used to perform single action for "batch" for file changes
# set to `true` to echo all file changes
DEBUG=false
FILE_CHANGE_BATCH_MARKER='--file-change-batch-end--'
fswatch --batch-marker="${FILE_CHANGE_BATCH_MARKER}" -0 . | xargs -0 -n 1 -I {} echo {} | while read file_path;
do
if $DEBUG; then
echo $file_path;
fi
# run block if file change batch marker is output
if [ "$file_path" = "$FILE_CHANGE_BATCH_MARKER" ]; then
echo $file_path;
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment