@matheusbsbs / matheus-bagliano / commits / b5a49471f0
Fork 0

Automatically autoload bashcompinit for ZSH, when needed

If bashcompinit has not already been autoloaded, do so automatically, as it is required to properly parse the git-completion file with ZSH. Helped-by: Felipe Contreras Signed-off-by: Marius Storm-Olsen <mstormo@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Marius Storm-Olsen committed Apr 26, 2011 at 22:23 UTC b5a49471f0a0b243468b09db349968e9a27b7334
1 file changed +8 -8
contrib/completion/git-completion.bash
+8 -8
@@ -1,6 +1,6 @@
1 #!bash
2 #
3 -# bash completion support for core Git.
3 +# bash/zsh completion support for core Git.
4 #
5 # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
6 # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
@@ -18,16 +18,12 @@
18 # To use these routines:
19 #
20 # 1) Copy this file to somewhere (e.g. ~/.git-completion.sh).
21 -# 2) Added the following line to your .bashrc:
22 -# source ~/.git-completion.sh
23 -#
24 -# Or, add the following lines to your .zshrc:
25 -# autoload bashcompinit
26 -# bashcompinit
21 +# 2) Add the following line to your .bashrc/.zshrc:
22 # source ~/.git-completion.sh
23 #
24 # 3) Consider changing your PS1 to also show the current branch:
30 -# PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
25 +# Bash: PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
26 +# ZSH: PS1='[%n@%m %c$(__git_ps1 " (%s)")]\$ '
27 #
28 # The argument to __git_ps1 will be displayed only if you
29 # are currently in a git repository. The %s token will be
@@ -77,6 +73,10 @@
73 # git@vger.kernel.org
74 #
75
76 +if [[ -n ${ZSH_VERSION-} ]]; then
77 + autoload -U +X bashcompinit && bashcompinit
78 +fi
79 +
80 case "$COMP_WORDBREAKS" in
81 *:*) : great ;;
82 *) COMP_WORDBREAKS="$COMP_WORDBREAKS:"