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

旧巷老猫 提交于 2020-01-22 07:20:27

问题


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


回答1:


Take a look at Extended Bash Completion




回答2:


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:


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




回答4:


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.




回答5:


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



来源:https://stackoverflow.com/questions/777017/how-to-enable-tab-completion-of-command-line-switches-in-bash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!