Last active
May 6, 2025 09:57
-
-
Save philipjohn/f28724f5f3c627e78e6c585d7074ccc4 to your computer and use it in GitHub Desktop.
Watch the current folder for changes and sync them to somewhere
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
# USAGE: watch_sync [destination_folder] | |
# Watch and sync a folder | |
watch_sync() { | |
# The first and only argument is the folder to sync to. | |
TO=$(echo "$1" | sed 's/\/$//') | |
# We assume the current folder is the one to sync from. | |
FROM=$(pwd) | |
# Now sync changes every second. | |
while ( true ); do | |
rsync -a --delete --exclude '.git' --exclude 'node_modules' --exclude 'vendor' "$FROM/" "$TO/" | |
sleep 1 | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment