git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
* Shell completion for branch names
@ 2021-04-07 14:23 jost.schulte
  0 siblings, 0 replies; 4+ messages in thread
From: jost.schulte @ 2021-04-07 14:23 UTC (permalink / raw)
  To: Git

Hello guys,

I have a question regarding git-completion. I'm using zsh and have added the function .git-completion.bash. That gives me some auto-completion for branch names.

What I'm looking for: I have a branch named "feature/issue-123-add-feature" for example. I'd like to type "git switch 123[tab]". Is there some function out there that provides this?

Cheers
Jost


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

* Re: Shell completion for branch names
  2021-04-07 14:23 jost.schulte
  2021-04-07 19:52 ` Junio C Hamano
@ 2021-04-07 20:00 ` Jeff King
  1 sibling, 0 replies; 4+ messages in thread
From: Jeff King @ 2021-04-07 20:00 UTC (permalink / raw)
  To: jost.schulte; +Cc: Git

On Wed, Apr 07, 2021 at 04:23:16PM +0200, jost.schulte@tutanota.com wrote:

> I have a question regarding git-completion. I'm using zsh and have
> added the function .git-completion.bash. That gives me some
> auto-completion for branch names.
> 
> What I'm looking for: I have a branch named
> "feature/issue-123-add-feature" for example. I'd like to type "git
> switch 123[tab]". Is there some function out there that provides this?

Generally completion is done left-to-right for a partial string. The
thing you are asking about is usually called "fuzzy" completion. You can
use that term to find some discussion and tools that may help (e.g.,
[1]). I don't use any myself, so I can't comment on the quality.

I'm also not sure if they can be used with custom completions like the
one Git provides. One of the things Git's completion code does is
turning those partial strings into a full set of options. In theory a
fuzzy completion system could just feed Git's completion code an empty
string to get all possibilities, and then do its own fuzzy match against
it. But again, I don't know if anybody has written the glue code to do
that kind of thing.

-Peff

[1] https://github.com/junegunn/fzf#fuzzy-completion-for-bash-and-zsh

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

* Re: Shell completion for branch names
  2021-04-07 14:23 jost.schulte
@ 2021-04-07 19:52 ` Junio C Hamano
  2021-04-07 20:00 ` Jeff King
  1 sibling, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2021-04-07 19:52 UTC (permalink / raw)
  To: jost.schulte; +Cc: Git

jost.schulte@tutanota.com writes:

> I have a question regarding git-completion. I'm using zsh and have
> added the function .git-completion.bash. That gives me some
> auto-completion for branch names.
>
> What I'm looking for: I have a branch named
> "feature/issue-123-add-feature" for example. I'd like to type "git
> switch 123[tab]". Is there some function out there that provides
> this?

I am not an area expert for shell completion, but as a mere user,
unless the shell completion in a directory where I have README.txt
file, responds to

    $ cat EAD<TAB>

and completes the request to

    $ cat README.txt

I would find such a behaviour quite confusing.

On the other hand if

    $ git log feat<TAB>

expands to

    $ git log feature/issue-

then another <TAB> after that would offer 123-add-feature and 143-fix
as candidates, or instead of <TAB> if I type "123<TAB>" and get it
expanded to the full feature/issue-123-add-feature, then I wouldn't
find it confusing or unnatural.

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

* Shell completion for branch names
@ 2021-04-07 14:23 jost.schulte
  2021-04-07 19:52 ` Junio C Hamano
  2021-04-07 20:00 ` Jeff King
  0 siblings, 2 replies; 4+ messages in thread
From: jost.schulte @ 2021-04-07 14:23 UTC (permalink / raw)
  To: Git

Hello guys,

I have a question regarding git-completion. I'm using zsh and have added the function .git-completion.bash. That gives me some auto-completion for branch names.

What I'm looking for: I have a branch named "feature/issue-123-add-feature" for example. I'd like to type "git switch 123[tab]". Is there some function out there that provides this?

Cheers
Jost


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

end of thread, other threads:[~2021-04-07 20:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-07 14:23 Shell completion for branch names jost.schulte
2021-04-07 14:23 jost.schulte
2021-04-07 19:52 ` Junio C Hamano
2021-04-07 20:00 ` Jeff King

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git