0

In bash, how does autocompletion know the options to complete a command?

For example,

  • when I hit key Tab after ls, it will list the files in the current directory.

  • when I hit key Tab after ebook-convert from calibre, it will list *.recipe.

Does the implementation of a program provide the handler of the Tab-hitting event?

Tim
  • 101,790
  • It depends on the program. Some programs provide it as part of their installation package, and some don't. Check the answer to the question above to see where those autocompletes come from. – aviro Aug 16 '23 at 08:40
  • It depends. Your distributions bash package might include (or depend on a package which includes) completions for some common programs, other programs have to include rules by themselves for any shell (e.g. zsh also supports custom completions) that it wants to offer good completions in. – Henrik supports the community Aug 16 '23 at 08:44
  • Shell TAB completion is part of the specific shell and not necessarily part of the program(s) implementation. Many completion files are provided by the original program developer, but some are provided by others in the community. See bash examples in /etc/bash_completion.d/ or /usr/share/bash-completion/completions/ – OldTimer Aug 22 '23 at 08:48

0 Answers0