Thread (1 message) 1 message, 1 author, 2021-04-07

Re: Shell completion for branch names

From: Junio C Hamano <hidden>
Date: 2021-04-07 19:52:32

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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help