#compdef rsx rxs # Strip leading wrapper arguments, then reuse zsh's native rsync completion # (including SSH hosts, remote paths, exclusions and rsync options). local -a modes wrapper_flags modes=( 'copy:copy/update files; keep destination-only files' 'preview:dry-run with an itemized change list' 'mirror:copy/update and delete destination-only files' 'cloud:copy into a mounted Google Drive / pCloud folder' 'raw:exact rsync without defaults or decoration' 'cheat:reference card' 'help:wrapper help' ) wrapper_flags=( '--cloud:add the cloud-folder flags to any mode' '--no-cloud:turn cloud-mount detection off' '--plain:native output with rsx defaults' '--command:print command without running it' '--help:wrapper help' '--version:wrapper version' ) local idx=2 mode=copy while (( idx < CURRENT )) && [[ ${words[idx]} == (--plain|--command|--cloud|--no-cloud) ]]; do (( idx++ )) done if (( CURRENT == idx )); then _describe -t commands 'rsx mode' modes _describe -t options 'rsx option' wrapper_flags fi if (( idx < CURRENT )) && [[ ${words[idx]} == (copy|preview|mirror|cloud|raw|cheat|help) ]]; then mode=${words[idx]} (( idx++ )) fi if [[ $mode == cheat ]]; then _values 'section' all copy preview mirror flags cloud style return fi if [[ $mode == help ]]; then return fi shift $(( idx - 1 )) words words=(rsync "${words[@]}") (( CURRENT -= idx - 2 )) _rsync "$@"