Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've just started using the Command-T plugin for vim, and it rocks. In case you haven't heard of it, it allows you to type something like this:

Sb

to select Something.hs-boot from the list

src/project/Control/Whatever/Foobs.hs
src/project/Control/Whatever/Something.hs-boot
src/project/Control/Whatever/Something.hs

And so on.

I was wondering if I could use a similar autocompletion style with zsh. I understand that the shell completion couldn't be nearly as extensive as the vim completion because the shell complition probably shouldn't be searching the entire system every time you type a letter, but is there some sort of similar completion where I could at least type

s/p/c/w/Sb<tab>

and get an effect similar to the one above?

I've heard that zsh has a pretty well-programmable autocomplete functionality, but my shell-fu is fairly weak.

Anybody know how to set this up?

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

To complete partial paths, it's enough to just init the completion system (at least on my system, using zsh v4.3.17):

autoload -U compinit && compinit
zmodload zsh/complist

If you want to get a little more fancy, you can make the matching case-insensitive:

zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'

Update 1:

I don't know if you can do Command-T-style autocompletion ... but as zsh has to get all matches before it displays something, doing this on-the-fly, especially somewhere that has a lot of subdirectories/files, might not be feasible.

You could however use:

**/*thing <Tab>

The ** matches all files & subdirectories of the current directory.

Idea: If it does not have to be an up-to-date list of files, you could potentially write a completion function that uses the output of locate (i.e. a pre-computed file list)

share|improve this answer
add comment

Another interesting alternative is to use something like fasd.

share|improve this answer
    
I second the recommendation for fasd. With fasd, you could simply type v Sb and it would open the file matching 'Sb' best in vim, according to time elapsed and frequency of edits of that file. –  simonair Feb 9 '13 at 5:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.