Bash Completion
In the May 2002 Power Tools column (http://www.linux-mag.com/2002-05/power_01.html), we looked at one of the most compelling features of zsh: its ability to complete often-used command-line arguments and switches. If you were tempted to drop bash in favor of zsh, don’t switch just yet — bash still has a few tricks up its sleeve.
Tuesday, October 15th, 2002
http://freshmeat.net/projects/bashcompletion
In the May 2002 Power Tools column (http://www.linux-mag.com/2002-05/power_01.html), we looked at one of the most compelling features of zsh: its ability to complete often-used command-line arguments and switches. If you were tempted to drop bash in favor of zsh, don’t switch just yet — bash still has a few tricks up its sleeve.
Hidden Secrets
bash, it turns out, is just as capable as zsh and every other shell out there. The big difference is that bash doesn’t come with all the smarts built-in. Instead, bash has hooks, and leaves the real programming work (or “fun”) in your hands (this is introduced on Ian Macdonald’s “Working More Productively with bash” page at http://www.caliban.org/bash/index.shtml#completion).
The bash completion project provides a large set of rules (i.e., bash shell functions) to determine the right way to “complete” various command lines.
For example, when you type ssh and hit the TAB key, bash, with the help of rules, reads and parses your ~/.ssh/known_hosts file and presents a list of all the hosts you’ve logged onto in the past.
Out of the Box
The bash completion definitions (in /etc/bash_completion) are available (but not configured) by default if you’re using Debian. Users of RedHat and other distributions need to download and install the appropriate RPM file. See Figure One for instructions on downloading and installing the RPM.