Skip to content

Instantly share code, notes, and snippets.

@Themitchell
Created January 27, 2016 13:33
Show Gist options
  • Save Themitchell/21baa9978e99df3f5e48 to your computer and use it in GitHub Desktop.
Save Themitchell/21baa9978e99df3f5e48 to your computer and use it in GitHub Desktop.
sk-vm-sync.sh
export DEV_VM_USERNAME=myusername
export DEV_VM_HOST=my.host.name
export DEV_VM_CODE_DIR=directory
sync() {
echo "Syncing $(basename $(pwd)) from $(pwd) to $DEV_VM_USERNAME@$DEV_VM_HOST:$DEV_VM_CODE_DIR/$(basename $(pwd))/"
rsync -avrx --delete --exclude=log --exclude=tmp --exclude=vendor/bundle --filter='P vendor/bundle' --exclude=.bundle --filter='P .bundle' --exclude=.git -e ssh . $DEV_VM_USERNAME@$DEV_VM_HOST:$DEV_VM_CODE_DIR/$(basename $(pwd))/
}
watch-sync() {
filewatcher_path=$(which filewatcher)
if [ -x $filewatcher_path ]; then
echo "Watching for changes and waiting to sync..."
filewatcher -i 0.2 '**/*' "rsync -avrx --delete --exclude=log --exclude=tmp --exclude=vendor/bundle --filter='P vendor/bundle' --exclude=.bundle --filter='P .bundle' --exclude=.git -e ssh . $DEV_VM_USERNAME@$DEV_VM_HOST:$DEV_VM_CODE_DIR/$(basename $(pwd))/"
else
echo "Cannot find filewatcher; Install using 'gem install filewatcher' and make sure it's in your path"
exit 1
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment