Created
January 19, 2020 13:51
-
-
Save elhardoum/e709c63021b73357d7877b465d7075d4 to your computer and use it in GitHub Desktop.
Live sync of your local project with a remote using rsync and monitoring file changes
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
#!/usr/bin/env sh | |
function syncfunc(){ | |
[ -f ./livesync.lock ] && exit -1 | |
touch /tmp/livesync.lock | |
command -v say > /dev/null && say synchronizing || echo synchronizing | |
rsync -r -a -v -e "ssh -p22" --delete ./ user@host-or-ip:/path/to/remote/folder/eg/root/project1 | |
command -v say > /dev/null && say synchronized || echo synchronized | |
rm -f /tmp/livesync.lock | |
} | |
export -f syncfunc | |
while true; do | |
touch ./.livesync-lastwatch | |
sleep 2 | |
find . -cnewer ./.livesync-lastwatch -exec bash -c 'syncfunc' \; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment