2001-11-29 18:08:01 +01:00
|
|
|
#compdef rsync
|
|
|
|
|
2002-03-17 20:00:29 +01:00
|
|
|
_rsync_remote_files() {
|
2004-08-07 16:28:31 +02:00
|
|
|
local expl remfiles remdispf remdispd remmodules suf ret=1 tag=accounts
|
2002-03-17 20:00:29 +01:00
|
|
|
|
2004-08-07 16:28:31 +02:00
|
|
|
if compset -P '*::*/'; then
|
2002-03-17 20:00:29 +01:00
|
|
|
|
2003-11-14 12:56:52 +01:00
|
|
|
remfiles=(${(f)"$(_call_program files rsync ${words[CURRENT]%/*}/)"})
|
2002-03-17 20:00:29 +01:00
|
|
|
|
|
|
|
remdispf=(${remfiles:#d*})
|
|
|
|
remdispd=(${(M)remfiles:#d*})
|
|
|
|
|
2003-11-14 12:56:52 +01:00
|
|
|
_wanted files expl 'remote file or directory' \
|
2002-03-17 20:00:29 +01:00
|
|
|
compadd -d remdispf ${remdispf##* }
|
2003-07-31 17:26:13 +02:00
|
|
|
|
2003-11-14 12:56:52 +01:00
|
|
|
_wanted files expl 'remote file or directory' \
|
2002-03-17 20:00:29 +01:00
|
|
|
compadd -S/ -d remdispd ${remdispd##* }
|
|
|
|
|
2004-08-07 16:28:31 +02:00
|
|
|
elif compset -P 1 '*::'; then
|
2002-03-17 20:00:29 +01:00
|
|
|
|
2003-11-14 12:56:52 +01:00
|
|
|
remfiles=(${(f)"$(_call_program files rsync ${words[CURRENT]%::*}::)"})
|
2002-03-17 20:00:29 +01:00
|
|
|
|
|
|
|
remmodules=(${remfiles/[ ]#/:})
|
|
|
|
|
|
|
|
_describe "remote modules" remmodules -S/
|
|
|
|
|
2004-08-07 16:28:31 +02:00
|
|
|
elif compset -P 1 '*:'; then
|
2002-03-17 20:00:29 +01:00
|
|
|
|
2004-08-07 16:28:31 +02:00
|
|
|
if zstyle -T ":completion:${curcontext}:files" remote-access; then
|
|
|
|
remfiles=(${(M)${(f)"$(_call_program files ssh -a -x ${IPREFIX%:} ls -d1FL "${(Q)PREFIX%%[^./][^/]#}\*" 2>/dev/null)"}%%[^/]#(|/)})
|
|
|
|
compset -P '*/'
|
|
|
|
compset -S '/*' || suf='remote file'
|
2002-03-17 20:00:29 +01:00
|
|
|
|
|
|
|
remdispf=(${remfiles:#*/})
|
|
|
|
remdispd=(${(M)remfiles:#*/})
|
|
|
|
|
2004-08-07 16:28:31 +02:00
|
|
|
_tags files
|
|
|
|
while _tags; do
|
|
|
|
while _next_label files expl ${suf:-remote directory}; do
|
|
|
|
[[ -n $suf ]] && compadd "$@" "$expl[@]" -d remdispf \
|
|
|
|
${(q)remdispf%[*=@|]} && ret=0
|
|
|
|
compadd ${suf:+-S/} "$@" "$expl[@]" -d remdispd \
|
|
|
|
${(q)remdispd%/} && ret=0
|
|
|
|
done
|
|
|
|
(( ret )) || return 0
|
|
|
|
done
|
2002-03-17 20:00:29 +01:00
|
|
|
else
|
2004-08-07 16:28:31 +02:00
|
|
|
_message -e remote-files 'remote file'
|
2002-03-17 20:00:29 +01:00
|
|
|
fi
|
|
|
|
|
2004-08-07 16:28:31 +02:00
|
|
|
elif compset -P 1 '*@'; then
|
2002-03-17 20:00:29 +01:00
|
|
|
local user=${PREFIX%%@*}
|
|
|
|
|
|
|
|
compset -S ':*' || suf=":"
|
|
|
|
|
|
|
|
_wanted -C user-at hosts expl "host for $user" \
|
|
|
|
_combination -s '[:@]' "${tag}" users-hosts users="$user" hosts -S "$suf" "$@" -
|
|
|
|
else
|
2003-07-31 17:26:13 +02:00
|
|
|
if compset -S '@*'; then
|
|
|
|
_wanted users expl "user" \
|
|
|
|
_combination -s '[:@]' "${tag}" users-hosts users -q "$@" -
|
|
|
|
else
|
2003-11-14 12:56:52 +01:00
|
|
|
_alternative 'users:user:_users -S @' 'hosts:host:_hosts -S:'
|
2003-07-31 17:26:13 +02:00
|
|
|
fi
|
2002-03-17 20:00:29 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
_rsync_files() {
|
2003-11-14 12:56:52 +01:00
|
|
|
_alternative "files:file:_files" "remote-files:remote file:_rsync_remote_files"
|
2002-03-17 20:00:29 +01:00
|
|
|
}
|
|
|
|
|
2003-07-31 17:26:13 +02:00
|
|
|
_arguments -s \
|
|
|
|
'*: :_rsync_files' \
|
|
|
|
'*'{-v,--verbose}'[increase verbosity]' \
|
|
|
|
'(-q --quiet)'{-q,--quiet}'[show less information during transfer]' \
|
|
|
|
'(-c --checksum)'{-c,--checksum}'[always checksum]' \
|
|
|
|
'(-a --archive)'{-a,--archive}'[archive mode]' \
|
|
|
|
'(-r --recursive)'{-r,--recursive}'[recurse into directories]' \
|
|
|
|
'(-E --relative)'{-R,--relative}'[use relative path names]' \
|
|
|
|
'(-b --backup)'{-b,--backup}'[make backups]' \
|
|
|
|
'--backup-dir[make backups into specified directory]:backup directory:_directories' \
|
|
|
|
'--suffix=[override backup suffix]:suffix' \
|
|
|
|
'(-u --update)'{-u,--update}'[update only]' \
|
2004-10-07 09:43:44 +02:00
|
|
|
'(-K --keep-dirlinks)'{-K,--keep-dirlinks}'[symlinked dir on receiver matches sender dir]' \
|
2003-07-31 17:26:13 +02:00
|
|
|
'(-l --links)'{-l,--links}'[copy symlinks as symlinks]' \
|
|
|
|
'(-L --copy-links)'{-L,--copy-links}'[treat soft links like regular files]' \
|
|
|
|
'--copy-unsafe-links[copy links outside the source tree]' \
|
|
|
|
'--safe-links[ignore links outside the destination tree]' \
|
|
|
|
'(-H --hard-links)'{-H,--hard-links}'[preserve hard links]' \
|
|
|
|
'(-p --perms)'{-p,--perms}'[preserve permissions]' \
|
|
|
|
'(-o --owner)'{-o,--owner}'[preserve owner]' \
|
|
|
|
'(-g --group)'{-g,--group}'[preserve group]' \
|
|
|
|
'(-D --devices)'{-D,--devices}'[preserve devices]' \
|
|
|
|
'(-t --times)'{-t,--times}'[preserve times]' \
|
|
|
|
'(-S --sparse)'{-S,--sparse}'[handle sparse files efficiently]' \
|
|
|
|
'(-n --dry-run)'{-n,--dry-run}'[show what would have been transferred]' \
|
|
|
|
'(-W --whole-file --no-whole-file)'{-W,--whole-file}'[copy whole files]' \
|
|
|
|
'(-W --whole-file)--no-whole-file[always use incremental rsync algorithm]' \
|
|
|
|
'(-x --one-file-system)'{-x,--one-file-system}'[do not cross filesystem boundaries]' \
|
|
|
|
'(-B --block-size)'{-B,--block-size=}'[checksum blocking size]:block size' \
|
|
|
|
'(-e --rsh)'{-e,--rsh}'[rsh command]:remote command:(rsh ssh)' \
|
|
|
|
'--rsync-path=[specify path to rsync on the remote machine]:remote command:' \
|
|
|
|
'(-C --cvs-exclude)'{-C,--cvs-exclude}'[autoignore files in the same way as CVS]' \
|
|
|
|
'--existing[only update files that already exist]' \
|
|
|
|
'--ignore-existing[ignore files that already exist on the receiving side]' \
|
2004-10-07 09:43:44 +02:00
|
|
|
'--inplace[update destination files inplace (SEE MAN PAGE)]' \
|
2003-07-31 17:26:13 +02:00
|
|
|
'--delete[delete files that do not exist on the sending side]' \
|
|
|
|
'--delete-excluded[also delete excluded files on the receiving side]' \
|
|
|
|
'--delete-after[perform delete after transferring]' \
|
|
|
|
'--ignore-errors[delete even if there are IO errors]' \
|
|
|
|
'--max-delete=[do not delete more than NUM files]:number:' \
|
|
|
|
'(-P)--partial[keep partially transferred files]' \
|
2004-10-07 09:43:44 +02:00
|
|
|
'--partial-dir=[put a partially transferred file in specified directory]:directory:_files -/' \
|
2003-07-31 17:26:13 +02:00
|
|
|
'--force[force deletion of directories even if not empty]' \
|
|
|
|
'--numeric-ids[do not map uid/gid values by user/group name]' \
|
|
|
|
'--timeout=[set IO timeout in seconds]:seconds:' \
|
|
|
|
'(-I --ignore-times)'{-I,--ignore-times}'[do not exclude files that match length and time]' \
|
|
|
|
'--size-only[only use file size when determining if a file should be transferred]' \
|
|
|
|
'--modify-window=[timestamp window for file match]:seconds:' \
|
|
|
|
'(-T --temp-dir)'{-T,--temp-dir=}'[create temporary files in specified directory]:directory:_files -/' \
|
|
|
|
'--compare-dest=[also compare destination files relative to specified directory]:directory:_files -/' \
|
|
|
|
'(--partial --progress)-P[equivalent to --partial --progress]' \
|
|
|
|
'(-z --compress)'{-z,--compress}'[compress file data]' \
|
|
|
|
'--exclude=[exclude files matching pattern]:pattern:' \
|
|
|
|
'--exclude-from=[exclude patterns listed in file]:file:_files' \
|
|
|
|
'--include=[do not exclude files matching pattern]:pattern:' \
|
|
|
|
'--include-from=[do not exclude patterns listed in file]:file:_files' \
|
|
|
|
'--version[print version number]' \
|
|
|
|
'--daemon[run as a rsync daemon]' \
|
|
|
|
'--no-detach[do not detach from the parent]' \
|
|
|
|
'--address=[bind to the specified address]:address:_hosts' \
|
|
|
|
'--config=[specify alternate rsyncd.conf file]:file:_files' \
|
|
|
|
'--port=[specify alternate rsyncd port number]:port:' \
|
|
|
|
'--blocking-io[use blocking IO for the remote shell]' \
|
|
|
|
'--no-blocking-io[turn off blocking IO when it is the default]' \
|
|
|
|
'--stats[give some file transfer stats]' \
|
|
|
|
'(-P)--progress[show progress during transfer]' \
|
|
|
|
'--log-format=[log file transfers using specified format]:format:' \
|
|
|
|
'--password-file=[get password from file]:file:_files' \
|
|
|
|
'--bwlimit=[limit bandwidth]:kbytes per second:' \
|
|
|
|
'--read-batch=[read batch file]:ext:' \
|
|
|
|
'--write-batch[write batch file]' \
|
|
|
|
'(-)'{-h,--help}'[display help information]' \
|
2004-10-07 09:43:44 +02:00
|
|
|
'(-4 --ipv4)'{-4,--ipv4}'[prefer IPv4]' \
|
|
|
|
'(-6 --ipv6)'{-6,--ipv6}'[prefer IPv6]' \
|
2003-07-31 17:26:13 +02:00
|
|
|
-- '*=COMMAND*:command:_command' \
|
|
|
|
'*=FILE*:file:_files' \
|
|
|
|
'*=DIR*:directory:_files -/'
|