How to enable tab-completion of command line switc

2019-03-15 05:43发布

With bash, I can complete a command with TAB. Normally, it should also complete the command line switches: e.g. 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

5条回答
forever°为你锁心
2楼-- · 2019-03-15 05:47

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.

查看更多
我命由我不由天
3楼-- · 2019-03-15 05:50

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

查看更多
\"骚年 ilove
4楼-- · 2019-03-15 05:51

If you want to create your own custom completions you can look at this post: https://stackoverflow.com/a/21476506/2649637

查看更多
Deceive 欺骗
5楼-- · 2019-03-15 05:56

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.

查看更多
6楼-- · 2019-03-15 06:05
登录 后发表回答