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 recently fallen in love with efficient text completion systems. One of my favourite kinds of completion is so-called fuzzy completion. This is a mode where the program will complete the user's input based on only a couple of characters that can occur 'anywhere' (almost) in the file name or path. This feature exists at least for these programs:

Usage example of this mode in a text editor:

User is trying to complete the word longWordNameThatTheyDontWantToWriteByHand, and they can do so by typing e.g. the first letter and some of the capital case letters. So typing lwnt could complete to the whole word.

My question is: is there a mode or something similar that I could use with the zsh shell?

share|improve this question

4 Answers 4

I'm not a zsh user. Just for your reference, here is a fuzzy matching module for Bash https://github.com/mgalgs/fuzzy_bash_completion

share|improve this answer

I've implemented one as a zle(zsh line editor) widget, you should check it out.

share|improve this answer
Hey, I'm wondering if you know of anything that can do this but with zsh command history. I'm content with doing my fuzzy filesystem searching via Vim and CtrlP (though I may set your zle widget up since it looks so awesome) but I really want to be able to fuzzy search my command history. –  Steven Lu May 30 '13 at 22:07
I don't know if theres something available, but it should be very easy to implement(I don't know how). Perhaps you can get some help in #zsh(freenode) –  Thiago de Arruda Jun 3 '13 at 19:32
unfortunately, I don't think I could justify going beyond history | agrep to do this sort of thing myself, currently. There have been times when I've really wanted to trace back my steps that I've forgotten. But regular grep (or regex-ing from less) has not failed me yet –  Steven Lu Jun 3 '13 at 19:37

Check out fzf.

It's a general purpose fuzzy finder written in Ruby that can be used with any list of things: files, processes, command history, git branches, etc.

There are some zsh widget examples on the page.

share|improve this answer

I have this in my .zshrc

# 0 -- vanilla completion (abc => abc)
# 1 -- smart case completion (abc => Abc)
# 2 -- word flex completion (abc => A-big-Car)
# 3 -- full flex completion (abc => ABraCadabra)
zstyle ':completion:*' matcher-list '' \
  'm:{a-z\-}={A-Z\_}' \
  'r:[^[:alpha:]]||[[:alpha:]]=** r:|=* m:{a-z\-}={A-Z\_}' \
  'r:[[:ascii:]]||[[:ascii:]]=** r:|=* m:{a-z\-}={A-Z\_}'

It adds full fuzzy matching to zsh's completion engine. It lacks the super smarts of sublime text, but, yes, it will complete lwnt -> longWordNameThatTheyDontWantToWriteByHand.

share|improve this answer

Your Answer


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.