惊喜! shell提示命令行开关 [英] Surprise! the shell suggests command line switches

查看:171
本文介绍了惊喜! shell提示命令行开关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到bash shell可以为您的命令建议命令行开关。



只需键入命令,破折号( - )和类型选项卡即可。

 <$ c $ 

c> andy @ andyx:〜$ java -

b
$ b



问题是:



如何与此功能介面。也就是说,如果我写了一个程序,要从控制台运行,什么是API告诉shell什么开关可用?

解决方案

您发现了Bash的可编程完成功能。


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!

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?

解决方案

You have discovered Bash's programmable completion feature.

这篇关于惊喜! shell提示命令行开关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆