From: Thomas Rast <trast@student.ethz.ch>
To: git@vger.kernel.org
Cc: Rob Sanheim <rsanheim@gmail.com>,
"Shawn O. Pearce" <spearce@spearce.org>
Subject: [FYI PATCH] bash completion: alias 'g' to 'git' with completion
Date: Fri, 3 Oct 2008 18:35:05 +0200 [thread overview]
Message-ID: <1223051705-30347-1-git-send-email-trast@student.ethz.ch> (raw)
In-Reply-To: <fc113d400810030825l75f9451dwc4cbf68807be0b5b@mail.gmail.com>
---
Rob Sanheim wrote:
> On Thu, Oct 2, 2008 at 11:10 PM, Shawn O. Pearce <spearce@spearce.org> wrote:
> > No, you'll need to alias 'g' to git in bash, and then if you still
> > want completion you'll need to also register the compgen to call
> > _git completion routine. Its two lines:
> >
> > alias g=git
> > complete -o default -o nospace -F _git g
>
> Thanks, that did it.
Actually it's not enough, you need to teach fetch, pull and push to
recognise the new alias too, as in this patch. I do wonder if there's
a better approach to those functions however, so that the "obvious"
fix suggested by Shawn would work.
- Thomas
contrib/completion/git-completion.bash | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 7284c3b..547e735 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -789,7 +789,7 @@ _git_fetch ()
git-fetch*,1)
__gitcomp "$(__git_remotes)"
;;
- git,2)
+ git,2|g,2)
__gitcomp "$(__git_remotes)"
;;
*)
@@ -1053,7 +1053,7 @@ _git_pull ()
git-pull*,1)
__gitcomp "$(__git_remotes)"
;;
- git,2)
+ git,2|g,2)
__gitcomp "$(__git_remotes)"
;;
*)
@@ -1075,7 +1075,7 @@ _git_push ()
git-push*,1)
__gitcomp "$(__git_remotes)"
;;
- git,2)
+ git,2|g,2)
__gitcomp "$(__git_remotes)"
;;
*)
@@ -1717,6 +1717,7 @@ _gitk ()
}
complete -o default -o nospace -F _git git
+complete -o default -o nospace -F _git g
complete -o default -o nospace -F _gitk gitk
# The following are necessary only for Cygwin, and only are needed
--
1.6.0.2.771.g3967
next prev parent reply other threads:[~2008-10-03 16:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-03 2:51 alias g to git in .gitconfig? Rob Sanheim
2008-10-03 3:10 ` Shawn O. Pearce
2008-10-03 15:25 ` Rob Sanheim
2008-10-03 16:35 ` Thomas Rast [this message]
2008-10-03 19:34 ` [PATCH] bash: remove fetch, push, pull dashed form leftovers SZEDER Gábor
2008-10-03 20:13 ` Thomas Rast
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=1223051705-30347-1-git-send-email-trast@student.ethz.ch \
--to=trast@student.ethz.ch \
--cc=git@vger.kernel.org \
--cc=rsanheim@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).