Skip to content

Commit 6bf931a

Browse files
committed
Merge branch 'fc/zsh-leftover-bits'
* fc/zsh-leftover-bits: completion: zsh: improve bash script loading completion: synchronize zsh wrapper completion: cleanup zsh wrapper
2 parents 727a46b + 3646b1a commit 6bf931a

File tree

2 files changed

+26
-23
lines changed

2 files changed

+26
-23
lines changed

contrib/completion/git-completion.bash

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2663,7 +2663,7 @@ if [[ -n ${ZSH_VERSION-} ]]; then
26632663
--*=*|*.) ;;
26642664
*) c="$c " ;;
26652665
esac
2666-
array[$#array+1]="$c"
2666+
array+=("$c")
26672667
done
26682668
compset -P '*[=:]'
26692669
compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
@@ -2689,22 +2689,14 @@ if [[ -n ${ZSH_VERSION-} ]]; then
26892689
compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
26902690
}
26912691

2692-
__git_zsh_helper ()
2693-
{
2694-
emulate -L ksh
2695-
local cur cword prev
2696-
cur=${words[CURRENT-1]}
2697-
prev=${words[CURRENT-2]}
2698-
let cword=CURRENT-1
2699-
__${service}_main
2700-
}
2701-
27022692
_git ()
27032693
{
2704-
emulate -L zsh
2705-
local _ret=1
2706-
__git_zsh_helper
2707-
let _ret && _default -S '' && _ret=0
2694+
local _ret=1 cur cword prev
2695+
cur=${words[CURRENT]}
2696+
prev=${words[CURRENT-1]}
2697+
let cword=CURRENT-1
2698+
emulate ksh -c __${service}_main
2699+
let _ret && _default && _ret=0
27082700
return _ret
27092701
}
27102702

contrib/completion/git-completion.zsh

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,17 @@
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

2019
complete ()
2120
{
@@ -27,7 +26,19 @@ zstyle -T ':completion:*:*:git:*' tag-order && \
2726
zstyle ':completion:*:*:git:*' tag-order 'common-commands'
2827

2928
zstyle -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
3142
ZSH_VERSION='' . "$script"
3243

3344
__gitcomp ()

0 commit comments

Comments
 (0)