Skip to content
Advertisement

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?

Advertisement

Answer

You have discovered Bash’s programmable completion feature.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement