git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Shell completion for branch names

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 7, 2021, 19:52 UTC
Message-ID
<xmqqr1jlzxc5.fsf@gitster.g>
In-Reply-To
<MXghkzC----2@tutanota.com>
jost.schulte@tutanota.com writes:
Show 8 quoted lines
> 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.

Previous: jost.schulte@tutanota.comNext: Jeff King
Message 2 of 3 in “Shell completion for branch names”
  1. jost.schulte@tutanota.comApr 7, 2021
  2. Junio C HamanoApr 7, 2021
  3. Jeff KingApr 7, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.