code.gitea.io/gitea@v1.21.7/contrib/autocompletion/zsh_autocomplete (about)

     1  #compdef ${PROG:=gitea}
     2  
     3  
     4  # Heavily inspired by https://github.com/urfave/cli
     5  
     6  _cli_zsh_autocomplete() {
     7  
     8    local -a opts
     9    local cur
    10    cur=${words[-1]}
    11    if [[ "$cur" == "-"* ]]; then
    12      opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} ${cur} --generate-bash-completion)}")
    13    else
    14      opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}")
    15    fi
    16  
    17    if [[ "${opts[1]}" != "" ]]; then
    18      _describe 'values' opts
    19    else
    20      _files
    21    fi
    22  
    23    return
    24  }
    25  
    26  if [ -z $PROG ] ; then
    27    compdef _cli_zsh_autocomplete gitea
    28  else
    29    compdef _cli_zsh_autocomplete $(basename $PROG)
    30  fi