Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable tab completion from the terminal specific to the executable

In bash, I believe it is possible to enable tab completion on the terminal for terms that are specific to the executable being invoked.

For example, given an executable "eat" with valid arguments {cake, carrot, banana}, typing 'eat car' should complete to 'eat carrot'.

I believe this is possible because I have seen it with 'ant' tab-completing its targets (though how this was set up I don't know).

How can this behaviour be implemented?

like image 542
Synesso Avatar asked Mar 14 '10 00:03

Synesso


1 Answers

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

If you only need to get the behaviour working for common executables, your Linux distro probably has a bash-completion package available with support for common commands.

like image 70
Martin Avatar answered Oct 17 '22 09:10

Martin