44#
55# Copyright (c) 2012-2013 Felipe Contreras <[email protected] >66#
7- # You need git's bash completion script installed somewhere, by default on the
8- # same directory as this script .
7+ # You need git's bash completion script installed somewhere, by default it
8+ # would be the location bash-completion uses .
99#
10- # If your script is on ~/.git-completion.sh instead, you can configure it on
11- # your ~/.zshrc:
10+ # If your script is somewhere else, you can configure it on your ~/.zshrc:
1211#
1312# zstyle ':completion:*:*:git:*' script ~/.git-completion.sh
1413#
15- # The recommended way to install this script is to copy to
16- # '~/.zsh/completion/_git', and then add the following to your ~/.zshrc file:
14+ # The recommended way to install this script is to copy to '~/.zsh/_git', and
15+ # then add the following to your ~/.zshrc file:
1716#
18- # fpath=(~/.zsh/completion $fpath)
17+ # fpath=(~/.zsh $fpath)
1918
2019complete ()
2120{
@@ -27,7 +26,19 @@ zstyle -T ':completion:*:*:git:*' tag-order && \
2726 zstyle ' :completion:*:*:git:*' tag-order ' common-commands'
2827
2928zstyle -s " :completion:*:*:git:*" script script
30- test -z " $script " && script=" $( dirname ${funcsourcetrace[1]%:* } ) " /git-completion.bash
29+ if [ -z " $script " ]; then
30+ local -a locations
31+ local e
32+ locations=(
33+ ' /etc/bash_completion.d/git' # fedora, old debian
34+ ' /usr/share/bash-completion/completions/git' # arch, ubuntu, new debian
35+ ' /usr/share/bash-completion/git' # gentoo
36+ $( dirname ${funcsourcetrace[1]%:* } ) /git-completion.bash
37+ )
38+ for e in $locations ; do
39+ test -f $e && script=" $e " && break
40+ done
41+ fi
3142ZSH_VERSION=' ' . " $script "
3243
3344__gitcomp ()
0 commit comments