{"thread":{"id":"55446","subject":"Shell completion for branch names","startedAt":"2021-04-07T14:23:21Z","lastAt":"2021-04-07T20:00:52Z","messageCount":3,"participants":["jost.schulte@tutanota.com","Junio C Hamano","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"421124","messageId":"MXghkzC----2@tutanota.com","threadId":"55446","inReplyTo":null,"subject":"Shell completion for branch names","fromName":"","fromEmail":"jost.schulte@tutanota.com","sentAt":"2021-04-07T14:23:16Z","receivedAt":"2021-04-07T14:23:21Z","isPatch":false,"sender":{"key":"jost.schulte@tutanota.com","avatar":null},"body":"Hello guys,\n\nI 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.\n\nWhat 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?\n\nCheers\nJost\n\n"},{"id":"421142","messageId":"xmqqr1jlzxc5.fsf@gitster.g","threadId":"55446","inReplyTo":"MXghkzC----2@tutanota.com","subject":"Re: Shell completion for branch names","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-04-07T19:52:26Z","receivedAt":"2021-04-07T19:52:32Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"jost.schulte@tutanota.com writes:\n\n> I have a question regarding git-completion. I'm using zsh and have\n> added the function .git-completion.bash. That gives me some\n> auto-completion for branch names.\n>\n> What I'm looking for: I have a branch named\n> \"feature/issue-123-add-feature\" for example. I'd like to type \"git\n> switch 123[tab]\". Is there some function out there that provides\n> this?\n\nI am not an area expert for shell completion, but as a mere user,\nunless the shell completion in a directory where I have README.txt\nfile, responds to\n\n    $ cat EAD<TAB>\n\nand completes the request to\n\n    $ cat README.txt\n\nI would find such a behaviour quite confusing.\n\nOn the other hand if\n\n    $ git log feat<TAB>\n\nexpands to\n\n    $ git log feature/issue-\n\nthen another <TAB> after that would offer 123-add-feature and 143-fix\nas candidates, or instead of <TAB> if I type \"123<TAB>\" and get it\nexpanded to the full feature/issue-123-add-feature, then I wouldn't\nfind it confusing or unnatural.\n"},{"id":"421143","messageId":"YG4PccicS0eH9gKG@coredump.intra.peff.net","threadId":"55446","inReplyTo":"MXghkzC----2@tutanota.com","subject":"Re: Shell completion for branch names","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-04-07T20:00:49Z","receivedAt":"2021-04-07T20:00:52Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Apr 07, 2021 at 04:23:16PM +0200, jost.schulte@tutanota.com wrote:\n\n> I have a question regarding git-completion. I'm using zsh and have\n> added the function .git-completion.bash. That gives me some\n> auto-completion for branch names.\n> \n> What I'm looking for: I have a branch named\n> \"feature/issue-123-add-feature\" for example. I'd like to type \"git\n> switch 123[tab]\". Is there some function out there that provides this?\n\nGenerally completion is done left-to-right for a partial string. The\nthing you are asking about is usually called \"fuzzy\" completion. You can\nuse that term to find some discussion and tools that may help (e.g.,\n[1]). I don't use any myself, so I can't comment on the quality.\n\nI'm also not sure if they can be used with custom completions like the\none Git provides. One of the things Git's completion code does is\nturning those partial strings into a full set of options. In theory a\nfuzzy completion system could just feed Git's completion code an empty\nstring to get all possibilities, and then do its own fuzzy match against\nit. But again, I don't know if anybody has written the glue code to do\nthat kind of thing.\n\n-Peff\n\n[1] https://github.com/junegunn/fzf#fuzzy-completion-for-bash-and-zsh\n"}]}