diff options
Diffstat (limited to 'completions/rsync')
-rw-r--r-- | completions/rsync | 55 |
1 files changed, 26 insertions, 29 deletions
diff --git a/completions/rsync b/completions/rsync index b0f2d106..e8b75b1a 100644 --- a/completions/rsync +++ b/completions/rsync @@ -1,40 +1,44 @@ -# bash completion for rsync +# bash completion for rsync -*- shell-script -*- -have rsync && _rsync() { - # TODO: _split_longopt - - COMPREPLY=() - local cur prev - _get_comp_words_by_ref -n : cur prev + local cur prev words cword split + _init_completion -s -n : || return _expand || return 0 case $prev in - --config|--password-file|--include-from|--exclude-from) + --config|--password-file|--include-from|--exclude-from|--files-from|\ + --log-file|--write-batch|--only-write-batch|--read-batch) + compopt +o nospace _filedir return 0 ;; - -T|--temp-dir|--compare-dest) + -T|--temp-dir|--compare-dest|--backup-dir|--partial-dir|--copy-dest|\ + --link-dest) + compopt +o nospace _filedir -d return 0 ;; -e|--rsh) + compopt +o nospace COMPREPLY=( $( compgen -W 'rsh ssh' -- "$cur" ) ) return 0 ;; --compress-level) - COMPREPLY=( $( compgen -W '1 2 3 4 5 6 7 8 9' -- "$cur" ) ) + compopt +o nospace + COMPREPLY=( $( compgen -W '{1..9}' -- "$cur" ) ) return 0 ;; esac + $split && return 0 + case $cur in -*) COMPREPLY=( $( compgen -W '--verbose --quiet --no-motd --checksum \ --archive --recursive --relative --no-implied-dirs \ - --backup --backup-dir --suffix= --update --inplace --append \ + --backup --backup-dir= --suffix= --update --inplace --append \ --append-verify --dirs --old-dirs --links --copy-links \ --copy-unsafe-links --safe-links --copy-dirlinks \ --keep-dirlinks --hard-links --perms --executability --chmod= \ @@ -59,23 +63,22 @@ _rsync() --write-batch= --only-write-batch= --read-batch= --protocol= \ --iconv= --ipv4 --ipv6 --version --help --daemon --config= \ --no-detach' -- "$cur" ) ) + [[ $COMPREPLY == *= ]] || compopt +o nospace ;; *:*) - if type _scp_remote_files &>/dev/null; then - # find which remote shell is used - local i shell=ssh - for (( i=1; i < COMP_CWORD; i++ )); do - if [[ "${COMP_WORDS[i]}" == -@(e|-rsh) ]]; then - shell=${COMP_WORDS[i+1]} - break - fi - done - [ "$shell" = ssh ] && _scp_remote_files - fi + # find which remote shell is used + local i shell=ssh + for (( i=1; i < cword; i++ )); do + if [[ "${words[i]}" == -@(e|-rsh) ]]; then + shell=${words[i+1]} + break + fi + done + [ "$shell" = ssh ] && _xfunc ssh _scp_remote_files ;; *) _known_hosts_real -c -a "$cur" - type _scp_local_files &>/dev/null && _scp_local_files || _filedir + _xfunc ssh _scp_local_files ;; esac @@ -83,10 +86,4 @@ _rsync() } && complete -F _rsync -o nospace rsync -# Local variables: -# mode: shell-script -# sh-basic-offset: 4 -# sh-indent-comment: t -# indent-tabs-mode: nil -# End: # ex: ts=4 sw=4 et filetype=sh |