Skip to content

Instantly share code, notes, and snippets.

@mrdomino
Last active March 5, 2022 06:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrdomino/bfbbab56602d215ffafdc13b8696b27a to your computer and use it in GitHub Desktop.
Save mrdomino/bfbbab56602d215ffafdc13b8696b27a to your computer and use it in GitHub Desktop.
rsync source with destination every time any change occurs in source
#!/bin/sh
set -eu
trap "echo 'usage: $0 <pier> <base> [desk]' >&2" EXIT
pier=$1
base=$2
if [ 3 -eq $# ]; then
desk=$3
else
desk=base
fi
trap - EXIT
set -x
rsync -avL --delete $base/ $pier/$desk/
fswatch -o $base | xargs -n1 -I{} sh -c "rsync -avL --delete $base/ $pier/$desk/; date"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment