contrib / completion / git-completion.zshon commit Merge branch 'lf/bundle-verify-list-prereqs' (a6da9cb)
   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__gitcomp_file ()
  64{
  65        emulate -L zsh
  66
  67        local IFS=$'\n'
  68        compset -P '*[=:]'
  69        compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
  70}
  71
  72_git ()
  73{
  74        local _ret=1
  75        () {
  76                emulate -L ksh
  77                local cur cword prev
  78                cur=${words[CURRENT-1]}
  79                prev=${words[CURRENT-2]}
  80                let cword=CURRENT-1
  81                __${service}_main
  82        }
  83        let _ret && _default -S '' && _ret=0
  84        return _ret
  85}
  86
  87_git