contrib / completion / git-completion.zshon commit Merge branch 'jk/shortlog-no-wrap-doc' into maint (74abc17)
   1#compdef git gitk
   2
   3# zsh completion wrapper for git
   4#
   5# You need git's bash completion script installed somewhere, by default on the
   6# same directory as this script.
   7#
   8# If your script is on ~/.git-completion.sh instead, you can configure it on
   9# your ~/.zshrc:
  10#
  11#  zstyle ':completion:*:*:git:*' script ~/.git-completion.sh
  12#
  13# The recommended way to install this script is to copy to
  14# '~/.zsh/completion/_git', and then add the following to your ~/.zshrc file:
  15#
  16#  fpath=(~/.zsh/completion $fpath)
  17
  18complete ()
  19{
  20        # do nothing
  21        return 0
  22}
  23
  24zstyle -s ":completion:*:*:git:*" script script
  25test -z "$script" && script="$(dirname ${funcsourcetrace[1]%:*})"/git-completion.bash
  26ZSH_VERSION='' . "$script"
  27
  28__gitcomp ()
  29{
  30        emulate -L zsh
  31
  32        local cur_="${3-$cur}"
  33
  34        case "$cur_" in
  35        --*=)
  36                ;;
  37        *)
  38                local c IFS=$' \t\n'
  39                local -a array
  40                for c in ${=1}; do
  41                        c="$c${4-}"
  42                        case $c in
  43                        --*=*|*.) ;;
  44                        *) c="$c " ;;
  45                        esac
  46                        array+=("$c")
  47                done
  48                compset -P '*[=:]'
  49                compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
  50                ;;
  51        esac
  52}
  53
  54__gitcomp_nl ()
  55{
  56        emulate -L zsh
  57
  58        local IFS=$'\n'
  59        compset -P '*[=:]'
  60        compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
  61}
  62
  63_git ()
  64{
  65        local _ret=1
  66        () {
  67                emulate -L ksh
  68                local cur cword prev
  69                cur=${words[CURRENT-1]}
  70                prev=${words[CURRENT-2]}
  71                let cword=CURRENT-1
  72                __${service}_main
  73        }
  74        let _ret && _default -S '' && _ret=0
  75        return _ret
  76}
  77
  78_git