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.

Let's say I have the following files in the directory:

  • abc123ABC
  • abc123QWE
  • abc456

Now suppose I type a and hit TAB.

In bash the completion as it usually works would just complete abc and stop with me having to "resolve" the next symbol. so if I type 1 I'll be able to complete to abc123 with the next TAB.

In zsh, at least in the way it is configured on my machine it will complete the whole variant, the first one in this case: abc123ABC and present me with the menu to change that to other variants.

This is usually good, but it turns out ugly and completely useless when there are a lot of files to complete. usually in such cases it would be easy/trivial to narrow down the choices by typing a couple of characters after the 'common' part.

I like the menu part but I'd really prefer for it to only complete the 'common' parts and complete in full on second TAB or using menu, but still w/o losing the ability to manually narrow the choices by typing a character or two.

Is there anything like that supported in zsh?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

You should explore the compinstall completion customization program.

autoload -Uz compinstall && compinstall

In the version that I am using (zsh 4.3.10), the option for inserting unambiguous prefixes is inside the following menu

  • 3 “Styles for changing the way completions are displayed and inserted.”
    • 2 “Change how completions are inserted: …”
      • 1 “… insert any unambiguous prefix rather than [going] straight to menu completion”
        • y

Once saved, this results in the following command saved to the completion customization file (usually .zshrc):

zstyle ':completion:*' insert-unambiguous true
  • 3 “Styles for changing the way completions are displayed and inserted.”
    • 3 “Configure … completion lists, selection of items, …”
      • 2 “Use cursor keys to select completions from completion lists.”
        • 1
        • Return

Once saved, this results in the following customization:

zstyle ':completion:*' menu select=1
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s

You might like to customize the first one by adding interactive:

zstyle ':completion:*' menu select=1 interactive
share|improve this answer
    
thanks, we are almost there... ;) at first it didn't work, then I tried to disable all my other completion settings and it did work. so I started to bisect the config and at the end the conflicting option is zstyle ':completion:*:*:*:*:*' menu yes select The problem is I really like it ;) the menu is good, I like to choose the options with the arrow keys. is it possible for them to work together? –  Vitaly Kushner Jul 7 '10 at 14:25
    
oh, btw, if you need, my zsh config is at github.com/astrails/dotzsh –  Vitaly Kushner Jul 7 '10 at 14:26

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.