13

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

Community
  • 1
  • 1
Burkhard
  • 14,596
  • 22
  • 87
  • 108
  • How do I add functionality to my command line scripts, so they too can offer auto completion for commands? (I have googled, but only get stuff about how to use it, and completion via history file) – Billy Moon Jul 01 '13 at 18:27

5 Answers5

11

Take a look at Extended Bash Completion

ShuggyCoUk
  • 36,004
  • 6
  • 77
  • 101
5

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

Stefan van den Akker
  • 6,661
  • 7
  • 48
  • 63
dunkyp
  • 178
  • 7
  • Don't know if the name changed but I needed to install `bash-completion` (with the dash), see also http://askubuntu.com/questions/86375/apt-get-autocomplete-package-name-is-broken – xZise Dec 16 '16 at 16:49
4

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.

Community
  • 1
  • 1
Joey
  • 344,408
  • 85
  • 689
  • 683
2

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

Community
  • 1
  • 1
AnandKumar Patel
  • 980
  • 9
  • 18
2

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.

Eddie
  • 53,828
  • 22
  • 125
  • 145