git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How to setup bash completion for alias of git command
@ 2013-01-12 14:30 Ping Yin
  2013-01-13  3:13 ` Ping Yin
  2013-01-20 11:14 ` Jonathan Nieder
  0 siblings, 2 replies; 4+ messages in thread
From: Ping Yin @ 2013-01-12 14:30 UTC (permalink / raw)
  To: git mailing list

Following setup works for me  in ubuntu (10.04,11.04) for a long time

alias gtlg='git log'
complete -o default -o nospace -F _git_log gtlg

However, in debian (testing, wheezy), it doesn't work

$ gtlg or<TAB>
gtlg or-bash: [: 1: unary operator expected
-bash: [: 1: unary operator expected

$ git --version
git version 1.7.10

Can anybody help?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to setup bash completion for alias of git command
  2013-01-12 14:30 How to setup bash completion for alias of git command Ping Yin
@ 2013-01-13  3:13 ` Ping Yin
  2013-01-20 11:14 ` Jonathan Nieder
  1 sibling, 0 replies; 4+ messages in thread
From: Ping Yin @ 2013-01-13  3:13 UTC (permalink / raw)
  To: git mailing list

On Sat, Jan 12, 2013 at 10:30 PM, Ping Yin <pkufranky@gmail.com> wrote:
> Following setup works for me  in ubuntu (10.04,11.04) for a long time
>
> alias gtlg='git log'
> complete -o default -o nospace -F _git_log gtlg
>
> However, in debian (testing, wheezy), it doesn't work
>
> $ gtlg or<TAB>
> gtlg or-bash: [: 1: unary operator expected
> -bash: [: 1: unary operator expected
>

with newest git version built with next branch, the same problem remains.

Ping Yin

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to setup bash completion for alias of git command
  2013-01-12 14:30 How to setup bash completion for alias of git command Ping Yin
  2013-01-13  3:13 ` Ping Yin
@ 2013-01-20 11:14 ` Jonathan Nieder
  2013-01-21  3:55   ` Ping Yin
  1 sibling, 1 reply; 4+ messages in thread
From: Jonathan Nieder @ 2013-01-20 11:14 UTC (permalink / raw)
  To: Ping Yin
  Cc: git mailing list, Felipe Contreras, Manlio Perillo, Marc Khouzam,
	SZEDER Gábor

Hi Ping,

Ping Yin wrote:

> Following setup works for me  in ubuntu (10.04,11.04) for a long time
>
> alias gtlg='git log'
> complete -o default -o nospace -F _git_log gtlg
>
> However, in debian (testing, wheezy), it doesn't work
>
> $ gtlg or<TAB>
> gtlg or-bash: [: 1: unary operator expected
> -bash: [: 1: unary operator expected

Yes, I can reproduce this.  "git bisect" tells me it was introduced
by v1.7.6-rc0~65^2~4 (completion: remove unnecessary
_get_comp_words_by_ref() invocations, 2011-04-28).  Since then, Felipe
has done work to make reusing subcommand completion easy again, so you
can do

	__git_complete gtlg _git_log

One complication: on some systems, including Ubuntu 13.04, git's bash
completion script is installed to

	/usr/share/bash-completion/completions/git

and sourced on the fly when completing commands starting with "git"
instead of right away from /etc/bash_completion.  On these systems,
the "__git_complete" function would not be usable right away from
your .bashrc file.  I think we should fix this, for example by moving
the function to a separate

	$(git --exec-path)/git-bashrc-functions

library.

Thanks for reporting,
Jonathan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to setup bash completion for alias of git command
  2013-01-20 11:14 ` Jonathan Nieder
@ 2013-01-21  3:55   ` Ping Yin
  0 siblings, 0 replies; 4+ messages in thread
From: Ping Yin @ 2013-01-21  3:55 UTC (permalink / raw)
  To: Jonathan Nieder
  Cc: git mailing list, Felipe Contreras, Manlio Perillo, Marc Khouzam,
	SZEDER Gábor

On Sun, Jan 20, 2013 at 7:14 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Hi Ping,
>
> Ping Yin wrote:
>>
>> However, in debian (testing, wheezy), it doesn't work
>>
>> $ gtlg or<TAB>
>> gtlg or-bash: [: 1: unary operator expected
>> -bash: [: 1: unary operator expected
>
> Yes, I can reproduce this.  "git bisect" tells me it was introduced
> by v1.7.6-rc0~65^2~4 (completion: remove unnecessary
> _get_comp_words_by_ref() invocations, 2011-04-28).  Since then, Felipe
> has done work to make reusing subcommand completion easy again, so you
> can do
>
>         __git_complete gtlg _git_log
>

Thanks very much. by following your advice, it works now.

Ping Yin

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-01-21  3:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-12 14:30 How to setup bash completion for alias of git command Ping Yin
2013-01-13  3:13 ` Ping Yin
2013-01-20 11:14 ` Jonathan Nieder
2013-01-21  3:55   ` Ping Yin

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).