简体   繁体   中英

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!

截图

The question is:

How do I interface with this feature. Ie, 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?

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

See:

$ man bash

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

仅供参考:在Ubuntu和/或Debian中,脚本位于/etc/bash_completion.d/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM