Skip to contentSkip to conversation

UI and git-completion.sh

DISCUSSION Paolo Ciarrocchi 8 participants 13 messages Jun 15, 2016 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

Hi all,
I just asked for help on the #git irc channel in order to install the .git-completion.sh script (thanks nessundorma) and after using it for a while I started wondering why I cannot find any reference to it the official documentation.
The only important think that git grep found is:

	paolo@paolo-desktop:~/git$ git grep completion *
	Documentation/RelNotes-1.5.0.txt: - Bash completion scripts have been updated heavily.
Shouldn't it be mentioned somewhere? 

I know that newbies are somehow scared by the following:

	paolo@paolo-desktop:~/git$ git-
	Display all 151 possibilities? (y or n)
What? Do I have to learn 151 commands?
No way!

Using the git-completation script it all boils down to 48 commands.

paolo@paolo-desktop:~/git$ git 
add                   fetch                 rebase 
am                    filter-branch         rebase--interactive 
annotate              format-patch          relink 
apply                 fsck                  remote 
archive               gc                    repack 
bisect                get-tar-commit-id     request-pull 
blame                 grep                  reset 
branch                gui                   resolve 
bundle                imap-send             revert 
checkout              init                  rm 
checkout-index        instaweb              send-email 
cherry                log                   shortlog 
cherry-pick           lost-found            show 
citool                ls-files              show-branch 
clean                 ls-remote             show-ref 
clone                 ls-tree               stash 
commit                merge                 status 
config                mergetool             submodule 
convert-objects       mv                    tag 
count-objects         name-rev              var 
describe              pickaxe               verify-pack 
diff                  pull                  whatchanged 
diff-stages           push

And I think I can remove some commands from the list.

What people think about starting suggesting the usage of the script in the documentation? I just want to know the opinion of the list before trying to write a documentation patch. Next step would be to reduce the number of the items listed by git <tab> but I know there is already a discussion about it on the list.

Regards,
Paolo

#1 lore raw
Quoted 2 lines · Paolo Ciarrocchi

What people think about starting suggesting the usage of the script in the documentation?

Also might be worth mentioning the zsh completion support. (I know it's there, but haven't used it -- maybe its author would care to describe it a bit?)

-Steve

#2 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Steven" == Steven Grimm <[email protected]> writes:

Steven> Also might be worth mentioning the zsh completion support. (I know it's there, Steven> but haven't used it -- maybe its author would care to describe it a bit?)

Where is it? I'm a zsh user, and would love to have git support.

Signature · 4 lines
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[email protected]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
#3 lore raw
Quoted 2 lines · Randal L. Schwartz

Where is it? I'm a zsh user, and would love to have git support.

Another way to get git-completion support with zsh (works with 4.3.2) is to use the existing bash-completion and enable bash-completion for zsh via:
autoload bashcompinit
bashcompinit
in your .zshrc or similar. Btw, if you use gentoo you can install git with bash-completion, although i suppose that most people here are not using emerge to get their git ;).

Greetings,
Johannes

Signature · 4 lines
Johannes Gilger <[email protected]>
http://hackvalue.de/heipei/
GPG-Key: 0x42F6DE81
GPG-Fingerprint: BB49 F967 775E BB52 3A81  882C 58EE B178 42F6 DE81
#4 lore raw
In reply to Randal L. Schwartz
Quoted 6 lines · [email protected] (Randal L. Schwartz) writes:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Steven" == Steven Grimm <[email protected]> writes:

Steven> Also might be worth mentioning the zsh completion support. (I know it's there, Steven> but haven't used it -- maybe its author would care to describe it a bit?)

Where is it? I'm a zsh user, and would love to have git support.

In zsh itself.

Completion/Unix/Command/_git

Signature · 1 line
Matthieu
#5 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Matthieu" == Matthieu Moy <[email protected]> writes:

Matthieu> In zsh itself.

Matthieu> Completion/Unix/Command/_git

Not in my version of zsh. Any chance I can add that to my 4.2.3 installation?

Signature · 4 lines
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[email protected]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Steven" == Steven Grimm <[email protected]> writes:

Steven> And I think we've just proven that more documentation is required Steven> here! (I have no idea how to enable it myself; I just know I've seen Steven> it mentioned on the list from time to time.)

Yes, so what is the process of adding the git zsh completion to any relatively stable version of zsh? Someone here must know.

Signature · 4 lines
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[email protected]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
#8 lore raw
Quoted 2 lines · Randal L. Schwartz

Yes, so what is the process of adding the git zsh completion to any relatively stable version of zsh? Someone here must know.

I dunno the "right" way to do it, but I had this in my .zshrc file that I presumably cargo-culted from somewhere:

fpath=( $HOME/.zsh/compfuncs $fpath )

So in addition to that, doing:

wget -O ~/.zsh/compfuncs/_git 'http://zsh.cvs.sourceforge.net/*checkout*/zsh/zsh/Completion/Unix/Command/_git'

might get you something. I guess if your zsh is too old it might be incompatible with the completion script, though...

-bcd

#9 lore raw
Quoted 4 lines · Brian Downing

I dunno the "right" way to do it, but I had this in my .zshrc file that I presumably cargo-culted from somewhere:

fpath=( $HOME/.zsh/compfuncs $fpath )

I think this has to come before "compinit" or whatever starts up the new completion engine.

-bcd

#10 lore raw
In reply to Randal L. Schwartz
Quoted 8 lines · [email protected] (Randal L. Schwartz) writes:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Matthieu" == Matthieu Moy <[email protected]> writes:

Matthieu> In zsh itself.

Matthieu> Completion/Unix/Command/_git

Not in my version of zsh. Any chance I can add that to my 4.2.3 installation?

http://zsh.cvs.sourceforge.net/zsh/zsh/Completion/Unix/Command/_git

Try adding it to your $fpath, hopefully, the new _git doesn't use the other new zsh features, and it will work (I have a CVS _git with a 4.3.4 zsh, and it works like a charm).

Signature · 1 line
Matthieu
#11 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Matthieu" == Matthieu Moy <[email protected]> writes:

Matthieu> http://zsh.cvs.sourceforge.net/zsh/zsh/Completion/Unix/Command/_git

Matthieu> Try adding it to your $fpath, hopefully, the new _git doesn't use the Matthieu> other new zsh features, and it will work (I have a CVS _git with a Matthieu> 4.3.4 zsh, and it works like a charm).

Do I add it as _git below my $fpath? Or do I need to put it into a subdir? How will it know it is there?

Signature · 4 lines
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[email protected]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
#12 lore raw
In reply to Paolo Ciarrocchi

Hi,

Quoted 18 lines · Paolo Ciarrocchi

Using the git-completation script it all boils down to 48 commands.

paolo@paolo-desktop:~/git$ git 
add                   fetch                 rebase 
am                    filter-branch         rebase--interactive 
annotate              format-patch          relink 
apply                 fsck                  remote 
archive               gc                    repack 
bisect                get-tar-commit-id     request-pull 
blame                 grep                  reset 
branch                gui                   resolve 
bundle                imap-send             revert 
checkout              init                  rm 
checkout-index        instaweb              send-email 
cherry                log                   shortlog 
cherry-pick           lost-found            show 
citool                ls-files              show-branch 
clean                 ls-remote             show-ref 
Quoted 8 lines
clone                 ls-tree               stash 
commit                merge                 status 
config                mergetool             submodule 
convert-objects       mv                    tag 
count-objects         name-rev              var 
describe              pickaxe               verify-pack 
diff                  pull                  whatchanged 
diff-stages           push

diff-stages just struck my eye. It is no longer in git... But AFAICS it is no longer in git-completion.bash either.

Besides, I think that the number of commands could be reduced further. For example, I think that a regular user does not want to see

checkout-index, citool, convert-objects, filter-branch, get-tar-commit-id, imap-send, instaweb, lost-found, ls-tree, name-rev, rebase--interactive, relink, repack, request-pull, show-ref, var, verify-pack and whatchanged.

This list was not vs the quoted list, but my current list (pretty much tip of Shawn's "next".

Note: I would like to complete the _options_ when one of these subcommands was specified, but I just do not want to see them when entering "git<SPACE><TAB>".

BTW Pierre's idea of generating many (if not all) of these completions on the fly (maybe with "--help-completion"?) is intriguing.

Ciao,
Dscho

#13 lore raw
Quoted 2 lines · Johannes Schindelin

BTW Pierre's idea of generating many (if not all) of these completions on the fly (maybe with "--help-completion"?) is intriguing.

To be fair, it's not my idea, I'm just bought to it.

Signature · 3 lines
·O·  Pierre Habouzit
··O                                                [email protected]
OOO                                                http://www.madism.org