{"thread":{"id":"15763","subject":"alias g to git in .gitconfig?","startedAt":"2008-10-03T02:51:31Z","lastAt":"2008-10-03T20:13:01Z","messageCount":6,"participants":["Rob Sanheim","Shawn O. Pearce","Thomas Rast","SZEDER Gábor"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"92215","messageId":"fc113d400810021951hf95ff35qb1ccb4af45a71abe@mail.gmail.com","threadId":"15763","inReplyTo":null,"subject":"alias g to git in .gitconfig?","fromName":"Rob Sanheim","fromEmail":"rsanheim@gmail.com","sentAt":"2008-10-03T02:51:31Z","receivedAt":"2008-10-03T02:51:31Z","isPatch":false,"sender":{"key":"rsanheim@gmail.com","avatar":"https://gravatar.com/avatar/d0241c8c582bf684cf1124f30a6024ae599a33e213bbd1f79d23727a212c8f48?d=mp&s=160"},"body":"This is pretty trivial, but I'm a lazy typist.\n\nIs it possible to alias 'g' to git via git config, instead of via\nbash?  If I do a plain bash alias then none of the nice autocompletion\nfrom git-contrib work with 'g'.\n\n- Rob\n"},{"id":"92216","messageId":"20081003031014.GA24367@spearce.org","threadId":"15763","inReplyTo":"fc113d400810021951hf95ff35qb1ccb4af45a71abe@mail.gmail.com","subject":"Re: alias g to git in .gitconfig?","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-10-03T03:10:14Z","receivedAt":"2008-10-03T03:10:14Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Rob Sanheim <rsanheim@gmail.com> wrote:\n> This is pretty trivial, but I'm a lazy typist.\n> \n> Is it possible to alias 'g' to git via git config, instead of via\n> bash?  If I do a plain bash alias then none of the nice autocompletion\n> from git-contrib work with 'g'.\n\nNo, you'll need to alias 'g' to git in bash, and then if you still\nwant completion you'll need to also register the compgen to call\n_git completion routine.  Its two lines:\n\n\talias g=git\n\tcomplete -o default -o nospace -F _git g\n\n-- \nShawn.\n"},{"id":"92256","messageId":"fc113d400810030825l75f9451dwc4cbf68807be0b5b@mail.gmail.com","threadId":"15763","inReplyTo":"20081003031014.GA24367@spearce.org","subject":"Re: alias g to git in .gitconfig?","fromName":"Rob Sanheim","fromEmail":"rsanheim@gmail.com","sentAt":"2008-10-03T15:25:53Z","receivedAt":"2008-10-03T15:25:53Z","isPatch":false,"sender":{"key":"rsanheim@gmail.com","avatar":"https://gravatar.com/avatar/d0241c8c582bf684cf1124f30a6024ae599a33e213bbd1f79d23727a212c8f48?d=mp&s=160"},"body":"Thanks, that did it.\n\nOn Thu, Oct 2, 2008 at 11:10 PM, Shawn O. Pearce <spearce@spearce.org> wrote:\n> Rob Sanheim <rsanheim@gmail.com> wrote:\n>> This is pretty trivial, but I'm a lazy typist.\n>>\n>> Is it possible to alias 'g' to git via git config, instead of via\n>> bash?  If I do a plain bash alias then none of the nice autocompletion\n>> from git-contrib work with 'g'.\n>\n> No, you'll need to alias 'g' to git in bash, and then if you still\n> want completion you'll need to also register the compgen to call\n> _git completion routine.  Its two lines:\n>\n>        alias g=git\n>        complete -o default -o nospace -F _git g\n>\n> --\n> Shawn.\n>\n"},{"id":"92260","messageId":"1223051705-30347-1-git-send-email-trast@student.ethz.ch","threadId":"15763","inReplyTo":"fc113d400810030825l75f9451dwc4cbf68807be0b5b@mail.gmail.com","subject":"[FYI PATCH] bash completion: alias 'g' to 'git' with completion","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2008-10-03T16:35:05Z","receivedAt":"2008-10-03T16:35:05Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"---\n\nRob Sanheim wrote:\n> On Thu, Oct 2, 2008 at 11:10 PM, Shawn O. Pearce <spearce@spearce.org> wrote:\n> > No, you'll need to alias 'g' to git in bash, and then if you still\n> > want completion you'll need to also register the compgen to call\n> > _git completion routine.  Its two lines:\n> >\n> >        alias g=git\n> >        complete -o default -o nospace -F _git g\n>\n> Thanks, that did it.\n\nActually it's not enough, you need to teach fetch, pull and push to\nrecognise the new alias too, as in this patch.  I do wonder if there's\na better approach to those functions however, so that the \"obvious\"\nfix suggested by Shawn would work.\n\n- Thomas\n\n\n contrib/completion/git-completion.bash |    7 ++++---\n 1 files changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 7284c3b..547e735 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -789,7 +789,7 @@ _git_fetch ()\n \tgit-fetch*,1)\n \t\t__gitcomp \"$(__git_remotes)\"\n \t\t;;\n-\tgit,2)\n+\tgit,2|g,2)\n \t\t__gitcomp \"$(__git_remotes)\"\n \t\t;;\n \t*)\n@@ -1053,7 +1053,7 @@ _git_pull ()\n \tgit-pull*,1)\n \t\t__gitcomp \"$(__git_remotes)\"\n \t\t;;\n-\tgit,2)\n+\tgit,2|g,2)\n \t\t__gitcomp \"$(__git_remotes)\"\n \t\t;;\n \t*)\n@@ -1075,7 +1075,7 @@ _git_push ()\n \tgit-push*,1)\n \t\t__gitcomp \"$(__git_remotes)\"\n \t\t;;\n-\tgit,2)\n+\tgit,2|g,2)\n \t\t__gitcomp \"$(__git_remotes)\"\n \t\t;;\n \t*)\n@@ -1717,6 +1717,7 @@ _gitk ()\n }\n \n complete -o default -o nospace -F _git git\n+complete -o default -o nospace -F _git g\n complete -o default -o nospace -F _gitk gitk\n \n # The following are necessary only for Cygwin, and only are needed\n-- \n1.6.0.2.771.g3967\n"},{"id":"92270","messageId":"20081003193449.GA24821@neumann","threadId":"15763","inReplyTo":"1223051705-30347-1-git-send-email-trast@student.ethz.ch","subject":"[PATCH] bash: remove fetch, push, pull dashed form leftovers","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2008-10-03T19:34:49Z","receivedAt":"2008-10-03T19:34:49Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"We don't provide complation for git-commands in dashed form anymore,\nso there is no need to keep those cases.\n\nSigned-off-by: SZEDER Gábor <szeder@ira.uka.de>\n---\n\nOn Fri, Oct 03, 2008 at 06:35:05PM +0200, Thomas Rast wrote:\n> Actually it's not enough, you need to teach fetch, pull and push to\n> recognise the new alias too, as in this patch.  I do wonder if there's\n> a better approach to those functions however, so that the \"obvious\"\n> fix suggested by Shawn would work.\n\nMaybe something like this?\n\n\n contrib/completion/git-completion.bash |   36 ++++++++------------------------\n 1 files changed, 9 insertions(+), 27 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 95c81f9..5a4e8c8 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -784,14 +784,9 @@ _git_fetch ()\n {\n \tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n \n-\tcase \"${COMP_WORDS[0]},$COMP_CWORD\" in\n-\tgit-fetch*,1)\n+\tif [ \"$COMP_CWORD\" = 2 ]; then\n \t\t__gitcomp \"$(__git_remotes)\"\n-\t\t;;\n-\tgit,2)\n-\t\t__gitcomp \"$(__git_remotes)\"\n-\t\t;;\n-\t*)\n+\telse\n \t\tcase \"$cur\" in\n \t\t*:*)\n \t\t\tlocal pfx=\"\"\n@@ -810,8 +805,7 @@ _git_fetch ()\n \t\t\t__gitcomp \"$(__git_refs2 \"$remote\")\"\n \t\t\t;;\n \t\tesac\n-\t\t;;\n-\tesac\n+\tfi\n }\n \n _git_format_patch ()\n@@ -1051,36 +1045,25 @@ _git_pull ()\n {\n \tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n \n-\tcase \"${COMP_WORDS[0]},$COMP_CWORD\" in\n-\tgit-pull*,1)\n-\t\t__gitcomp \"$(__git_remotes)\"\n-\t\t;;\n-\tgit,2)\n+\tif [ \"$COMP_CWORD\" = 2 ]; then\n \t\t__gitcomp \"$(__git_remotes)\"\n-\t\t;;\n-\t*)\n+\telse\n \t\tlocal remote\n \t\tcase \"${COMP_WORDS[0]}\" in\n \t\tgit-pull)  remote=\"${COMP_WORDS[1]}\" ;;\n \t\tgit)       remote=\"${COMP_WORDS[2]}\" ;;\n \t\tesac\n \t\t__gitcomp \"$(__git_refs \"$remote\")\"\n-\t\t;;\n-\tesac\n+\tfi\n }\n \n _git_push ()\n {\n \tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n \n-\tcase \"${COMP_WORDS[0]},$COMP_CWORD\" in\n-\tgit-push*,1)\n-\t\t__gitcomp \"$(__git_remotes)\"\n-\t\t;;\n-\tgit,2)\n+\tif [ \"$COMP_CWORD\" = 2 ]; then\n \t\t__gitcomp \"$(__git_remotes)\"\n-\t\t;;\n-\t*)\n+\telse\n \t\tcase \"$cur\" in\n \t\t*:*)\n \t\t\tlocal remote\n@@ -1104,8 +1087,7 @@ _git_push ()\n \t\t\t__gitcomp \"$(__git_refs)\"\n \t\t\t;;\n \t\tesac\n-\t\t;;\n-\tesac\n+\tfi\n }\n \n _git_rebase ()\n-- \n1.6.0.2.474.ga74ad.dirty\n"},{"id":"92274","messageId":"200810032213.06005.trast@student.ethz.ch","threadId":"15763","inReplyTo":"20081003193449.GA24821@neumann","subject":"Re: [PATCH] bash: remove fetch, push, pull dashed form leftovers","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2008-10-03T20:13:01Z","receivedAt":"2008-10-03T20:13:01Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"SZEDER Gábor wrote:\n> We don't provide complation for git-commands in dashed form anymore,\n> so there is no need to keep those cases.\n[...]\n> On Fri, Oct 03, 2008 at 06:35:05PM +0200, Thomas Rast wrote:\n> > I do wonder if there's a better approach to those functions\n> > however, so that the \"obvious\" fix suggested by Shawn would work.\n> \n> Maybe something like this?\n\nThat's indeed much simpler and better.  FWIW,\n\nTested-by: Thomas Rast <trast@student.ethz.ch>\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n\n"}]}