views:

195

answers:

6

Bash lets you complete commands names and names of files in the arguments with the TAB key. But why not also common options to commands? Why not, even better, a completion system that tells you what an option does, too?

I heard of programmable completion.. but don't understand where it fits..

So my question is: is there a way to achieve what I ask? Other tools to combine with Bash maybe.. or anything?

+1  A: 

It's a standard feature of bash: programmable completion.

Ned Batchelder
+1  A: 

Bash does support argument completion: http://www.debian-administration.org/articles/316

vrutberg
+1  A: 

Bash completion is very customisable and can display options to common commands. The configuration file just need to specify so. In Debian, bash completion comes with an assorted set of configuration files that complete options for different commands.

For example:

alanhaggai@neon:~$ tar
A  c  d  r  t  u  x
Alan Haggai Alavi
+1  A: 

Here's the official man page of bash: Bash Reference Manual: Programmable Completion

tangens
+1  A: 

On OS X, you can easily install a set of predefined bash completions using MacPorts by following the instructions here. Looking at the examples in /opt/local/etc/bash_completion.d may give you some ideas for making additional ones.

Ned Deily
+2  A: 

If you want even more awesome completion, look into zsh. It's very much like bash, and takes some of the good features from ksh, tcsh, etc. It also fixes a few of the annoying bash bugs.

It can do some pretty cool stuff, including completing remote filenames for scp (if you have key-based authentication set up) and mini-documentation when you tab complete For example, I was pleasantly surprised when I tabbed on "jar" the other day:

[steven@sexy:~]% jar <tab>
0  -- store only without using ZIP compression
M  -- do not create manifest file
etc...
Steven Schlansker