1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-07-02 19:57:12 -07:00
rc/sh/autosync

19 lines
400 B
Plaintext
Raw Normal View History

2017-11-04 06:25:51 -07:00
#!/usr/bin/env zsh
2021-07-29 00:37:35 -07:00
# YES_ZSH
# NO_BASH
# NO_DASH
# TODO: portable way of dodging aliases to allow other shell support?
2021-07-29 00:37:35 -07:00
2017-11-04 06:25:51 -07:00
autosync() {
target="$1"
shift
# as a reminder not to get the argument order mixed up:
echo -E "rsyncing to $target" >&2
while inotifywait -q -e create,modify "$@"; do
\rsync -rtl "$@" "$target"
done
}
2021-07-29 00:37:35 -07:00
[ "${SOURCING:-0}" -gt 0 ] || autosync "$@"