flybywire
flybywire

Reputation: 273492

Surprise! the shell suggests command line switches

I noticed that the bash shell can suggest command line switches for your command.

Just type your command, a dash (-) and type tab. The shell will show you available switches.

For example, try:

andy@andyx:~$ java -

and press tab - Surprise!

Screenshot

The question is:

How do I interface with this feature. I.e., if I write a program that is to be run from the console, what's the API to tell the shell what switches are available?

Upvotes: 16

Views: 6570

Answers (3)

MrX
MrX

Reputation:

FYI: In Ubuntu and/or Debian the scripts are at /etc/bash_completion.d/

Upvotes: 5

Alnitak
Alnitak

Reputation: 339816

See:

$ man bash

In particular, the section entitled "READLINE" and subsection "Programmable Completion"

Upvotes: 6

unwind
unwind

Reputation: 399803

You have discovered Bash's programmable completion feature.

Upvotes: 19

Related Questions