如何在 bash 中启用命令行开关的制表符完成?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/777017/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to enable tab-completion of command line switches in bash?
提问by Burkhard
With bash
, I can complete a command with TAB. Normally, it should also complete the command line switches: e.g. when I typed:
使用bash
,我可以使用 TAB 完成命令。通常,它还应该完成命令行开关:例如,当我输入:
java -
it should show me the possibilities. It does not. How can I enable this preview?
它应该向我展示各种可能性。它不是。如何启用此预览?
采纳答案by ShuggyCoUk
Take a look at Extended Bash Completion
回答by Joey
Related: Surprise! the shell suggests command line switches
In the answers to that question there were several links to documentation. You might find what you look for there.
在该问题的答案中,有几个指向文档的链接。您可能会在那里找到您要找的东西。
回答by dunkyp
You need to have bash_completion
installed and then just add . /etc/bash_completion
to your .bashrc
.
您需要bash_completion
安装,然后添加. /etc/bash_completion
到您的.bashrc
.
回答by Eddie
Depending on what Linux flavor you're using, you may want to add a package. For Fedora and related distributions, you need to add the separate package bash-completion
to get this to work. 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.
根据您使用的 Linux 风格,您可能需要添加一个包。对于 Fedora 和相关发行版,您需要添加单独的包bash-completion
才能使其工作。如果其他发行版将它打包为可选的第二个包,除了包之外,您还需要添加它,我不会感到惊讶bash
。
回答by AnandKumar Patel
If you want to create your own custom completions you can look at this post: https://stackoverflow.com/a/21476506/2649637
如果您想创建自己的自定义完成,您可以查看这篇文章:https: //stackoverflow.com/a/21476506/2649637