I
I
Issue2021-11-19 22:00:29
linux
Issue, 2021-11-19 22:00:29

How to make entry by TAB in linux terminal?

I do not understand how the function execution works when pressing tab in the terminal.
For example, I want to write a utility with nested functionality.

[email protected]:~$ main [нажатие TAB]
snapshot save send
[email protected]:~$ main snapshot [нажатие TAB]
  -d	--dir		Каталог [./]
  -n	--name 		Имя "Снимок"

What is it written on? How to do this. For example, APT adds the name of packages by pressing TAB.
How does the terminal output that there are such packages and complete the names if the command is only entered but not yet executed?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Saboteur, 2021-11-20
@paulenot

bash completion is a large library of functions that can tab-complete
* alias
names * function
names * variable names
* command names
* filesystem paths
* options for some commands.
You can read the documentation on how to add an addon for your own commands - https://www.gnu.org/software/bash/manual/html_node...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question