Last active
May 28, 2016 06:42
-
-
Save mwcz/2986905 to your computer and use it in GitHub Desktop.
watchrun script for running a command when any file in the current dir tree changes
This file contains 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/sh | |
# USAGE: ./watchrun.sh COMMAND | |
# New credit to: http://exyr.org/2011/inotify-run/ | |
# this script will wait for changes in the current directory tree, and when one occurs, it will run COMMAND, then resume waiting | |
# requires inotify-tools: | |
# sudo apt-get install inotify-tools | |
# or: | |
# yum install inotify-tools | |
FORMAT=$(echo -e "\033[1;33m%w%f\033[0m written") | |
while inotifywait -e close_write -qr --format "$FORMAT" . | |
do | |
"$@" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment