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

Re: Some sub-commands can't be completed by TAB key.

From
Philippe Blain <levraiphilippeblain@gmail.com>
Date
Jan 23, 2022, 17:31 UTC
Message-ID
<5a30ac1f-d414-0976-cd08-7b059117af41@gmail.com>
In-Reply-To
<CAGP6PO+GMi6jqRZ5HWxES5GDYkEDHoXOOZ+VvDkm0sC4nxkT4Q@mail.gmail.com>
Hi Hongyi,
Le 2022-01-22 à 19:38, Hongyi Zhao a écrit :
Show 24 quoted lines
> On Sat, Jan 22, 2022 at 10:47 PM Johannes Sixt <j6t@kdbg.org> wrote:
>>
>> Am 22.01.22 um 09:42 schrieb Hongyi Zhao:
>>> I find that there are some  sub-commands can't be completed by TAB key:
>>>
>>> $ git <TAB>
>>> add               cherry-pick       fetch             latexdiff
>>> [...]
>>> As you can see, there are some sub-commands which are not listed in
>>> the above list, for example, the following ones:
>>>
>>> $ git ls-remote
>>> $ git ls-files
>>>
>>> Any hints for this problem?
>>
>> Tab completion is only available for user-facing sub-commands
>> ("porcelain"), but not for sub-commands intended for scripting
>> ("plumbing"). The intent is to make tab completion more efficient during
>> day-to-day work on the command line. For example,
> 
> But there are so many git sub-commands, so if the plumbing feature is
> supported, it will facilitate user to check the availability of some
> sub-commands.

If what you want to do is "check the availability" of some sub-command, you can simply do 'git <subcommand> -h', for example, and see if Git recognizes the subcommand.

If you mean discovering Git commands, you can use 'git help -a', which will list all commands, including pluming commands.

If you want to customize the Bash completion so that some select plumbing commands do appear in the tab completion, you can use the config 'completion.commands' [1]. Setting it to "ls-files ls-remote ls-tree" would then give you your desired output below.

Show 11 quoted lines
> 
>>    $ git l<TAB>
>>
>> arrives at
>>
>>    $ git log <cursor here>
> 
> I see the following:
> 
> $ git l<TAB>
> latexdiff   log
This would mean you have a 'git-latexdiff' command somewhere in your PATH.
Hope that helps,
Philippe.
[1] https://git-scm.com/docs/git-config#Documentation/git-config.txt-completioncommands
Previous: Hongyi ZhaoNext: Junio C Hamano
Message 4 of 17 in “Some sub-commands can't be completed by TAB key.”
  1. Hongyi ZhaoJan 22, 2022
  2. Johannes SixtJan 22, 2022
  3. Hongyi ZhaoJan 23, 2022
  4. Philippe BlainJan 23, 2022
  5. Junio C HamanoJan 23, 2022
  6. Hongyi ZhaoJan 24, 2022
  7. João Victor BonfimJan 24, 2022
  8. Junio C HamanoJan 25, 2022
  9. completion: add a GIT_COMPLETION_SHOW_ALL_COMMANDSÆvar Arnfjörð Bjarmason, Jan 25, 2022
  10. Junio C HamanoJan 26, 2022
  11. 0/2 completion: add a GIT_COMPLETION_SHOW_ALL_COMMANDSÆvar Arnfjörð Bjarmason, Feb 2, 2022
  12. 1/2 completion tests: re-source git-completion.bash in a subshellÆvar Arnfjörð Bjarmason, Feb 2, 2022
  13. 2/2 completion: add a GIT_COMPLETION_SHOW_ALL_COMMANDSÆvar Arnfjörð Bjarmason, Feb 2, 2022
  14. SZEDER GáborFeb 6, 2022
  15. Junio C HamanoFeb 6, 2022
  16. SZEDER GáborFeb 6, 2022
  17. Junio C HamanoFeb 7, 2022

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.