Where Are The Wise Men?

Mike's Ramblings

Zsh Completion Magic

| Comments

I'm a happy user of [zsh][]for a few years now and, while I don't know all the subtleties of it, I find it a indispensable tool. People I know and respect keep asking me "Why not bash?" One of the big reasons is [zsh's completion system.][]

Bash has a add-on version of this, called [bash-completion][], and I used that before moving over to zsh full-time. Bash-completion feels, well, added on and slow and not always working. Zsh's completion, however, keeps surprising me on how much it does do. As they say, a picture is worth a thousand words.

[caption id="attachment_722" align="aligncenter" width="300" caption="I typed "./manage.py TAB" and Zsh gave me all the arguments of a standard Django manage script."][![ZSH doing Django Completion][]][][/caption]

The above screenshot came with no configuration -- I didn't have to tell zsh about Django because, well, [someone already did][]. And I'm glad for it.

It's not just for Django, either. See what happened when I did "./configure " in PHP's source tree:

[caption id="attachment_724" align="aligncenter" width="300" caption="The top part is what I got when I did "./configure TAB". The part below my prompt is what I got when I did "./configure --with-TAB""][![Zsh when configuring soruce][]][][/caption]

So note that zsh helps me figure out the right options. What I want to know the exact options for MySQL?

[caption id="attachment_725" align="aligncenter" width="300" caption="Results of ./configure --with-mTAB"][![Results of ./configure --with-mTAB][]][][/caption]

Again, none of this stuff had to be configured -- I just told zsh I wanted completion and it gave it to me. I didn't have to tell it that this was a configure script -- it knew that! Just like it knew about the Django script.

This is just a taste. I hope you bite into zsh for more goodness.

"ZSH doing Django Completion"
"Zsh when configuring soruce"
"Results of ./configure --with-mTAB"