How to enable tab execution from terminal related to executable file

In bash, I believe that you can enable tab completion on the terminal for terms that are specific to the executable executable.

For example, if the executable file is "with" valid arguments (cake, carrot, banana), typing "eat car" should end with "eat carrot."

I believe that this is possible because I saw it with the "ant" tab - completing my goals (although I don’t know how this was set up).

How can this behavior be implemented?

+7
bash terminal tab-completion
source share
2 answers

This is done with scripts in /etc/bash_completion.d/ , and if you want to write your own completion support for the executable, here is a tutorial to get you started .

If you just need to make the behavior work for regular executables, your Linux distribution may have a bash -completion package available with support for common commands.

+9
source share

This is like filename globbing , where the shell will try to autocomplete based on a wildcard wildcard ... for example ....

 echo foo *

will display all files in the current directory, starting with 'foo' ... the bash globbed shell wildcard and expanded it to the list of files ...

MSDOS had a similar concept, although it was not explicitly tied at runtime, I'm talking about the old Turbo C thing, when wildcard pushing was activated by referencing "wildargs.obj" (if my memory serves me correctly), internally, this code will Go through the directory and expand the list based on a wildcard.

On Linux / * nix land, globbing is standard, but, however, you cannot manually press the Tab Tab key to perform pattern matching or completion ... since different terminals can translate the tab key differently and, of course, process it by differently ...

0
source share

All Articles