Skip to content

Instantly share code, notes, and snippets.

@2ec0b4
Created February 27, 2019 13:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 2ec0b4/fb35f4dee6048c658a19c0c22de6d7cf to your computer and use it in GitHub Desktop.
Save 2ec0b4/fb35f4dee6048c658a19c0c22de6d7cf to your computer and use it in GitHub Desktop.
Watch for file changes and do something
#!/bin/bash
# This script requires [entr](http://entrproject.org): `brew install entr`
# Tested on macOS Mojave
while true; do
# Watch for files changes or new files in the current directory, except in ./dist, ./vendor and ./.git, and execute ./do-something.sh
find . \( -path "./dist" -o -path "./vendor" -o -path "./.git" \) -prune -o -print | entr -d ./do-something.sh
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment