git-svn: teach find-rev to find near matches
[git/mjg.git] / contrib / completion / git-completion.zsh
blob45775021fff11011a98b90a6b8ebaa72d3d0cd9f
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 _git ()
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
74 let _ret && _default -S '' && _ret=0
75 return _ret
78 _git