1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-11-13 20:49:03 -08:00
rc/sh/autosync
Connor Olding d5f3f14d72 merge compatibility lines
RIP meaningful last-modified dates
2024-03-26 15:08:14 -07:00

18 lines
537 B
Bash
Executable file

#!/usr/bin/env zsh
# YES_ZSH NO_BASH NO_DASH NO_ASH
# TODO: portable way of dodging aliases to allow other shell support?
autosync() { ### @-
### combine `inotifywait` and `rsync`.
### this is sometimes nicer than `ssh`-ing into a server and running `vim` remotely.
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
}
[ -n "${preload+-}" ] || autosync "$@"