Last active
August 29, 2015 14:16
-
-
Save laem/fb342388383702c02d23 to your computer and use it in GitHub Desktop.
Watch for local changes, exluding according to ./.gitignore, to rsync to $dest
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/bash | |
# | |
# Fork of https://gist.github.com/senko/1154509#file-onchange-sh | |
if [ -z "$1" ]; then | |
echo "Specify an rsync dest as first argument" | |
exit -1; | |
fi | |
EVENTS="CREATE,CLOSE_WRITE,DELETE,MODIFY,MOVED_FROM,MOVED_TO" | |
inotifywait -e "$EVENTS" -m -r --format '%:e %f' . | ( | |
WAITING=""; | |
while true; do | |
LINE=""; | |
read -t 1 LINE; | |
if test -z "$LINE"; then | |
if test ! -z "$WAITING"; then | |
echo "CHANGE"; | |
WAITING=""; | |
fi; | |
else | |
WAITING=1; | |
fi; | |
done) | ( | |
while true; do | |
read TMP; | |
echo "yo" | |
rsync -avt --delete --filter=':- .gitignore' ./ $1 | |
done | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment