简体   繁体   中英

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

With bash , I can complete a command with 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

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.

You need to have bash_completion installed and then just add . /etc/bash_completion . /etc/bash_completion to your .bashrc .

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

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.

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