* alias g to git in .gitconfig?
@ 2008-10-03 2:51 Rob Sanheim
2008-10-03 3:10 ` Shawn O. Pearce
0 siblings, 1 reply; 6+ messages in thread
From: Rob Sanheim @ 2008-10-03 2:51 UTC (permalink / raw)
To: git
This is pretty trivial, but I'm a lazy typist.
Is it possible to alias 'g' to git via git config, instead of via
bash? If I do a plain bash alias then none of the nice autocompletion
from git-contrib work with 'g'.
- Rob
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: alias g to git in .gitconfig?
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
0 siblings, 1 reply; 6+ messages in thread
From: Shawn O. Pearce @ 2008-10-03 3:10 UTC (permalink / raw)
To: Rob Sanheim; +Cc: git
Rob Sanheim <rsanheim@gmail.com> wrote:
> This is pretty trivial, but I'm a lazy typist.
>
> Is it possible to alias 'g' to git via git config, instead of via
> bash? If I do a plain bash alias then none of the nice autocompletion
> from git-contrib work with 'g'.
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
--
Shawn.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: alias g to git in .gitconfig?
2008-10-03 3:10 ` Shawn O. Pearce
@ 2008-10-03 15:25 ` Rob Sanheim
2008-10-03 16:35 ` [FYI PATCH] bash completion: alias 'g' to 'git' with completion Thomas Rast
0 siblings, 1 reply; 6+ messages in thread
From: Rob Sanheim @ 2008-10-03 15:25 UTC (permalink / raw)
To: git
Thanks, that did it.
On Thu, Oct 2, 2008 at 11:10 PM, Shawn O. Pearce <spearce@spearce.org> wrote:
> Rob Sanheim <rsanheim@gmail.com> wrote:
>> This is pretty trivial, but I'm a lazy typist.
>>
>> Is it possible to alias 'g' to git via git config, instead of via
>> bash? If I do a plain bash alias then none of the nice autocompletion
>> from git-contrib work with 'g'.
>
> 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
>
> --
> Shawn.
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [FYI PATCH] bash completion: alias 'g' to 'git' with completion
2008-10-03 15:25 ` Rob Sanheim
@ 2008-10-03 16:35 ` Thomas Rast
2008-10-03 19:34 ` [PATCH] bash: remove fetch, push, pull dashed form leftovers SZEDER Gábor
0 siblings, 1 reply; 6+ messages in thread
From: Thomas Rast @ 2008-10-03 16:35 UTC (permalink / raw)
To: git; +Cc: Rob Sanheim, Shawn O. Pearce
---
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] bash: remove fetch, push, pull dashed form leftovers
2008-10-03 16:35 ` [FYI PATCH] bash completion: alias 'g' to 'git' with completion Thomas Rast
@ 2008-10-03 19:34 ` SZEDER Gábor
2008-10-03 20:13 ` Thomas Rast
0 siblings, 1 reply; 6+ messages in thread
From: SZEDER Gábor @ 2008-10-03 19:34 UTC (permalink / raw)
To: Thomas Rast; +Cc: git, Rob Sanheim, Shawn O. Pearce
We don't provide complation for git-commands in dashed form anymore,
so there is no need to keep those cases.
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
---
On Fri, Oct 03, 2008 at 06:35:05PM +0200, Thomas Rast wrote:
> 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.
Maybe something like this?
contrib/completion/git-completion.bash | 36 ++++++++------------------------
1 files changed, 9 insertions(+), 27 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 95c81f9..5a4e8c8 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -784,14 +784,9 @@ _git_fetch ()
{
local cur="${COMP_WORDS[COMP_CWORD]}"
- case "${COMP_WORDS[0]},$COMP_CWORD" in
- git-fetch*,1)
+ if [ "$COMP_CWORD" = 2 ]; then
__gitcomp "$(__git_remotes)"
- ;;
- git,2)
- __gitcomp "$(__git_remotes)"
- ;;
- *)
+ else
case "$cur" in
*:*)
local pfx=""
@@ -810,8 +805,7 @@ _git_fetch ()
__gitcomp "$(__git_refs2 "$remote")"
;;
esac
- ;;
- esac
+ fi
}
_git_format_patch ()
@@ -1051,36 +1045,25 @@ _git_pull ()
{
local cur="${COMP_WORDS[COMP_CWORD]}"
- case "${COMP_WORDS[0]},$COMP_CWORD" in
- git-pull*,1)
- __gitcomp "$(__git_remotes)"
- ;;
- git,2)
+ if [ "$COMP_CWORD" = 2 ]; then
__gitcomp "$(__git_remotes)"
- ;;
- *)
+ else
local remote
case "${COMP_WORDS[0]}" in
git-pull) remote="${COMP_WORDS[1]}" ;;
git) remote="${COMP_WORDS[2]}" ;;
esac
__gitcomp "$(__git_refs "$remote")"
- ;;
- esac
+ fi
}
_git_push ()
{
local cur="${COMP_WORDS[COMP_CWORD]}"
- case "${COMP_WORDS[0]},$COMP_CWORD" in
- git-push*,1)
- __gitcomp "$(__git_remotes)"
- ;;
- git,2)
+ if [ "$COMP_CWORD" = 2 ]; then
__gitcomp "$(__git_remotes)"
- ;;
- *)
+ else
case "$cur" in
*:*)
local remote
@@ -1104,8 +1087,7 @@ _git_push ()
__gitcomp "$(__git_refs)"
;;
esac
- ;;
- esac
+ fi
}
_git_rebase ()
--
1.6.0.2.474.ga74ad.dirty
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] bash: remove fetch, push, pull dashed form leftovers
2008-10-03 19:34 ` [PATCH] bash: remove fetch, push, pull dashed form leftovers SZEDER Gábor
@ 2008-10-03 20:13 ` Thomas Rast
0 siblings, 0 replies; 6+ messages in thread
From: Thomas Rast @ 2008-10-03 20:13 UTC (permalink / raw)
To: SZEDER Gábor; +Cc: git, Rob Sanheim, Shawn O. Pearce
[-- Attachment #1: Type: text/plain, Size: 528 bytes --]
SZEDER Gábor wrote:
> We don't provide complation for git-commands in dashed form anymore,
> so there is no need to keep those cases.
[...]
> On Fri, Oct 03, 2008 at 06:35:05PM +0200, Thomas Rast wrote:
> > I do wonder if there's a better approach to those functions
> > however, so that the "obvious" fix suggested by Shawn would work.
>
> Maybe something like this?
That's indeed much simpler and better. FWIW,
Tested-by: Thomas Rast <trast@student.ethz.ch>
--
Thomas Rast
trast@{inf,student}.ethz.ch
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-10-03 20:14 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [FYI PATCH] bash completion: alias 'g' to 'git' with completion Thomas Rast
2008-10-03 19:34 ` [PATCH] bash: remove fetch, push, pull dashed form leftovers SZEDER Gábor
2008-10-03 20:13 ` Thomas Rast
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).