git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marius Storm-Olsen <marius@storm-olsen.com>
To: "Shawn O. Pearce" <spearce@spearce.org>,
	Junio C Hamano <gitster@pobox.com>,
	Felipe Contreras <felipe.contreras@gmail.com>
Cc: git@vger.kernel.org, Marius Storm-Olsen <mstormo@gmail.com>
Subject: [PATCH v2] Automatically autoload bashcompinit for ZSH, when needed
Date: Tue, 26 Apr 2011 22:23:35 -0500	[thread overview]
Message-ID: <1303874615-24718-1-git-send-email-mstormo@gmail.com> (raw)
In-Reply-To: <BANLkTi=qzBGmp80088hVrc+yicH2ofDGEg@mail.gmail.com>

If bashcompinit has not already been autoloaded, do so
automatically, as it is required to properly parse the
git-completion file with ZSH.

Signed-off-by: Marius Storm-Olsen <mstormo@gmail.com>
---
 Changes since v2:
 -----------------
 'Added' -> 'Add'
 Simplified test for bashcompinit, as per advice from Felipe Contreras

 contrib/completion/git-completion.bash |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 840ae38..9150ea6 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -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/).
@@ -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
@@ -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:"
-- 
1.7.5.rc2.4.g4d8b3

      reply	other threads:[~2011-04-27  3:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-26 13:24 [PATCH] Refactor git-completion to allow ZSH usage of PS1 functions Marius Storm-Olsen
2011-04-26 17:21 ` Junio C Hamano
2011-04-26 17:37   ` Marius Storm-Olsen
2011-04-26 19:15     ` Junio C Hamano
2011-04-26 20:28       ` [PATCH] Automatically autoload bashcompinit for ZSH, when needed Marius Storm-Olsen
2011-04-26 20:47         ` Matthieu Moy
2011-04-26 20:52           ` Marius Storm-Olsen
2011-04-26 21:55             ` Junio C Hamano
2011-04-27  1:11         ` Felipe Contreras
2011-04-27  1:22           ` Felipe Contreras
2011-04-27  3:23             ` Marius Storm-Olsen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1303874615-24718-1-git-send-email-mstormo@gmail.com \
    --to=marius@storm-olsen.com \
    --cc=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=mstormo@gmail.com \
    --cc=spearce@spearce.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).