简体   繁体   English

如何在bash中启用命令行开关的tab-completion?

[英]How to enable tab-completion of command line switches in bash?

With bash , I can complete a command with TAB. 使用bash ,我可以用TAB完成一个命令。 Normally, it should also complete the command line switches: eg when I typed: 通常,它还应该完成命令行开关:例如,当我键入时:

java -

it should show me the possibilities. 它应该告诉我可能性。 It does not. 它不是。 How can I enable this preview? 如何启用此预览?

See also Surprise! 另见惊喜! the shell suggests command line switches shell建议命令行开关

Related: Surprise! 相关: 惊喜! the shell suggests command line switches shell建议命令行开关

In the answers to that question there were several links to documentation. 在该问题的答案中,有几个文档链接。 You might find what you look for there. 你可能会找到你在那里寻找的东西。

You need to have bash_completion installed and then just add . /etc/bash_completion 您需要安装bash_completion然后bash_completion添加. /etc/bash_completion . /etc/bash_completion to your .bashrc . . /etc/bash_completion到你的.bashrc

如果您想创建自己的自定义完成,可以查看以下帖子: https//stackoverflow.com/a/21476506/2649637

Depending on what Linux flavor you're using, you may want to add a package. 根据您正在使用的Linux风格,您可能需要添加一个包。 For Fedora and related distributions, you need to add the separate package bash-completion to get this to work. 对于Fedora和相关的发行版,您需要添加单独的包bash-completion以使其工作。 I wouldn't be surprised if other distributions had this packaged as an optional 2nd package that you need to add in addition to the bash package. 如果其他发行版打包为除了bash包之外需要添加的可选第二个包,我也不会感到惊讶。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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