Last active
May 28, 2016 04:36
-
-
Save fijiwebdesign/573f4028931c89c3eada to your computer and use it in GitHub Desktop.
Inotifywait watch files and run command
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 | |
# inotifywait-cmd.sh | |
# | |
# Example: | |
# inotifywait-cmd.sh test/ 'phpunit --verbose test/ModelReferencesTest.php' | |
# | |
# Requires: https://github.com/thekid/inotify-win on windows | |
# | |
# author: Gabe LG <[email protected]> | |
# license: MIT | |
# | |
# correct usage instructions | |
if [ "$#" -ne 2 ]; then | |
echo "Usage: | |
$0 path 'command' | |
Example: | |
$0 test/ 'phpunit --verbose test/ModelReferencesTest.php' | |
Note: | |
Exit with [Ctr+c] | |
" | |
exit 1 | |
fi | |
# start inotifywait and eval command when files change | |
while true; do | |
inotifywait -r $1 && eval $2 | |
sleep 1 # allow ctr+c | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment