Merge branch 'ap/maint-diff-rename-avoid-overlap' into maint
[git/jnareb-git.git] / contrib / completion / git-completion.zsh
blobcf8116d4770c5924eaa647763d2bfae3dc14bacf
1 #compdef git gitk
3 # zsh completion wrapper for git
5 # You need git's bash completion script installed somewhere, by default on the
6 # same directory as this script.
8 # If your script is on ~/.git-completion.sh instead, you can configure it on
9 # your ~/.zshrc:
11 # zstyle ':completion:*:*:git:*' script ~/.git-completion.sh
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:
16 # fpath=(~/.zsh/completion $fpath)
18 complete ()
20 # do nothing
21 return 0
24 zstyle -s ":completion:*:*:git:*" script script
25 test -z "$script" && script="$(dirname ${funcsourcetrace[1]%:*})"/git-completion.bash
26 ZSH_VERSION='' . "$script"
28 __gitcomp ()
30 emulate -L zsh
32 local cur_="${3-$cur}"
34 case "$cur_" in
35 --*=)
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
51 esac
54 __gitcomp_nl ()
56 emulate -L zsh
58 local IFS=$'\n'
59 compset -P '*[=:]'
60 compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
63 __gitcomp_file ()
65 emulate -L zsh
67 local IFS=$'\n'
68 compset -P '*[=:]'
69 compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
72 _git ()
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
83 let _ret && _default -S '' && _ret=0
84 return _ret
87 _git