Skip to content

Instantly share code, notes, and snippets.

@ayr-ton
Last active April 13, 2022 13:20
Show Gist options
  • Save ayr-ton/aff2bbacc465ef1ea833986bc2ff0d98 to your computer and use it in GitHub Desktop.
Save ayr-ton/aff2bbacc465ef1ea833986bc2ff0d98 to your computer and use it in GitHub Desktop.
Sync workspaces
#!/bin/bash
SYNC_SERVER=""
function enter_workspace() {
cd ~/workspace
}
function leave_workspace() {
cd -
}
function sync_external() {
rsync -zav --filter=':- .gitignore' --progress --delete ./ $1:workspace/
}
function sync_local() {
rsync -zav --filter=':- .gitignore' --progress --delete $SYNC_SERVER:workspace/ ./
}
function main() {
enter_workspace
if [ "$#" -eq "0" ]
then
sync_local
else
sync_external $1
fi
leave_workspace
}
main $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment