2017-11-04 06:25:51 -07:00
|
|
|
#!/usr/bin/env zsh
|
2024-07-22 05:28:58 -07:00
|
|
|
# compat: -ash -bash -dash +zsh
|
2021-07-29 05:44:12 -07:00
|
|
|
|
|
|
|
# TODO: portable way of dodging aliases to allow other shell support?
|
2021-07-29 00:37:35 -07:00
|
|
|
|
2021-07-30 17:57:08 -07:00
|
|
|
autosync() { ### @-
|
|
|
|
### combine `inotifywait` and `rsync`.
|
|
|
|
### this is sometimes nicer than `ssh`-ing into a server and running `vim` remotely.
|
2017-11-04 06:25:51 -07:00
|
|
|
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
|
|
|
|
2021-08-02 13:48:46 -07:00
|
|
|
[ -n "${preload+-}" ] || autosync "$@"
|