Created
April 9, 2016 03:42
-
-
Save bordoni/58227c92cf29ce09c8a345b63e86b7a5 to your computer and use it in GitHub Desktop.
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
| # !sh | |
| # Requires fswatch -- https://github.com/emcrisostomo/fswatch | |
| # Usage | |
| # wsync ~/wp-content/plugins ~/dev/tribe/* | |
| # wsync $destination $from | |
| function wsync { | |
| # First Param as the the place where the files will go | |
| to=$1 | |
| # All other Params are the folders to watch | |
| from=(`echo $(echo $@ | xargs -n1) | sed "s,${to} *,,g"`) | |
| # Exclude string | |
| rsync_exclude="--exclude=.git --exclude=node_modules --exclude=.sass-cache --exclude=.DS_Store --exclude=.svn" | |
| # Create the Arguments for `rsync` | |
| rsync_args="--archive --itemize-changes --checksum --times --perms --human-readable --delete ${from} ${to} ${rsync_exclude}" | |
| echo "\n ┏\"$to\"" | |
| # Output a nice log | |
| for line_from in $from; do | |
| echo " ┣━❱ \"$line_from\"" | |
| done | |
| echo " ┗┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉ \n" | |
| # Rsync when starting | |
| echo "┏┫`date +%H-%M-%S`┣┓" && echo "┡┉┉┉┉┉┉┉┉┉┉┩" && (`echo "rsync ${rsync_args}"`) && echo "┕┉┉┉┉┉┉┉┉┉┉┙\n" | |
| # Now watch for changes | |
| fswatch --one-per-batch --exclude=\.git $from | (while read; do echo "┏┫`date +%H-%M-%S`┣┓" && echo "┡┉┉┉┉┉┉┉┉┉┉┩" && (`echo "rsync ${rsync_args}"`) && echo "┕┉┉┉┉┉┉┉┉┉┉┙\n"; done) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment