Skip to content

Commit

Permalink
Automatically autoload bashcompinit for ZSH, when needed
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Marius Storm-Olsen authored and Junio C Hamano committed Apr 27, 2011
1 parent ec014ea commit b5a4947
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions contrib/completion/git-completion.bash
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!bash
#
# bash completion support for core Git.
# bash/zsh completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
Expand All @@ -18,16 +18,12 @@
# To use these routines:
#
# 1) Copy this file to somewhere (e.g. ~/.git-completion.sh).
# 2) Added the following line to your .bashrc:
# source ~/.git-completion.sh
#
# Or, add the following lines to your .zshrc:
# autoload bashcompinit
# bashcompinit
# 2) Add the following line to your .bashrc/.zshrc:
# source ~/.git-completion.sh
#
# 3) Consider changing your PS1 to also show the current branch:
# PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
# Bash: PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
# ZSH: PS1='[%n@%m %c$(__git_ps1 " (%s)")]\$ '
#
# The argument to __git_ps1 will be displayed only if you
# are currently in a git repository. The %s token will be
Expand Down Expand Up @@ -77,6 +73,10 @@
# git@vger.kernel.org
#

if [[ -n ${ZSH_VERSION-} ]]; then
autoload -U +X bashcompinit && bashcompinit
fi

case "$COMP_WORDBREAKS" in
*:*) : great ;;
*) COMP_WORDBREAKS="$COMP_WORDBREAKS:"
Expand Down

0 comments on commit b5a4947

Please sign in to comment.