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.

" />
x
Loading
 Loading
Hello, Guest | Login | Register

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.

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.

Please log in to view this content.

Not Yet a Member?

Register with LinuxMagazine.com and get free access to the entire archive, including:

  • Hands-on Content
  • White Papers
  • Community Features
  • And more.
Already a Member?
Log in!
Username

Password

Remember me

Forgotten your password?
Forgotten your username?
Read More
  1. Helpful Tools for Software Developers
  2. The Github Hall of Fame
  3. Book'em, Github.
  4. This Week on Github: Stupid Ruby Tricks
  5. A Veritable Scatter Shot!
Follow Linux Magazine
Rackspace