Last active
April 13, 2022 13:20
-
-
Save ayr-ton/aff2bbacc465ef1ea833986bc2ff0d98 to your computer and use it in GitHub Desktop.
Sync workspaces
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 | |
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