A relatively new feature in bash is programmable completion, which has been available since the beta version of 2.04. Programmable completion will be familiar to you if you are a zsh user. It also exists, albeit in a much less usable form, in tcsh.
It's much easier to demonstrate programmable completion than it is to explain it, so I suggest installing one of the files below and trying it out. If you don't like it, you can always disable it for a particular command, disable it completely, or remove it from your system. bash programmable completion can be installed and removed very cleanly, so you shouldn't be wary of giving it a whirl.
Here are some key features of "bash programmable completion":
- Path-name completion:
- This type of completion occurs on the first token of the command line, allowing you to complete on executable files. Together with file-name completion, it is the most known and used type.
- File-name completion:
- This allows you to complete on file and directory names at the second and subsequent token position on the command line.
- User-name completion:
- This allows you to complete on user names by prefixing the token with a ~ (tilde).
- Host-name completion:
- This allows you to complete on host names by prefixing the token with a @.
- Variable-name completion:
- This allows you to complete on variable names by prefixing the token with a $.
- This version adds numerous new and improved completions and bugfixes.