惊喜!在shell提示命令行开关

惊喜!在shell提示命令行开关

问题描述:

我注意到,在bash shell可以建议的命令行对您的命令切换。

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.

例如,尝试:

andy@andyx:~$ java -

和preSS标签 - !惊喜

and press tab - Surprise!

现在的问题是:

如何使用此功能接口。即,如果我写一个程序,是从控制台运行,有什么API来告诉shell哪些开关可用?

您已经发现猛砸的的可编程完成功能。

You have discovered Bash's programmable completion feature.