completion: zsh: update slave script locations

Update the default locations of typical system bash-completion, including the default bash-completion location for user scripts, and the recommended way to find the system location (with pkg-config). Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Felipe Contreras committed Oct 27, 2020 at 20:06 UTC 98fc2684a90bfb9edaae2cb8d5129b4ca7698ddc
1 file changed +9 -5
contrib/completion/git-completion.zsh
+9 -5
@@ -13,7 +13,7 @@
13 # fpath=(~/.zsh $fpath)
14 #
15 # You need git's bash completion script installed. By default bash-completion's
16 -# location will be used (e.g. /usr/share/bash-completion/completions/git).
16 +# location will be used (e.g. pkg-config --variable=completionsdir bash-completion).
17 #
18 # If your bash completion script is somewhere else, you can specify the
19 # location in your ~/.zshrc:
@@ -33,12 +33,16 @@ zstyle -T ':completion:*:*:git:*' tag-order && \
33 zstyle -s ":completion:*:*:git:*" script script
34 if [ -z "$script" ]; then
35 local -a locations
36 - local e
36 + local e bash_completion
37 +
38 + bash_completion=$(pkg-config --variable=completionsdir bash-completion 2>/dev/null) ||
39 + bash_completion='/usr/share/bash-completion/completions/'
40 +
41 locations=(
42 "$(dirname ${funcsourcetrace[1]%:*})"/git-completion.bash
39 - '/etc/bash_completion.d/git' # fedora, old debian
40 - '/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian
41 - '/usr/share/bash-completion/git' # gentoo
43 + "$HOME/.local/share/bash-completion/completions/git"
44 + "$bash_completion/git"
45 + '/etc/bash_completion.d/git' # old debian
46 )
47 for e in $locations; do
48 test -f $e && script="$e" && break