Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I find zsh's result lists for Tab completion quite useful, however I'd like to tweak their behaviour a bit:

They should appear when I Tab for the first time and afterwards dynamically update with every new letter added. The default behaviour is that the suggestions are only re-evaluated when you Tab again, I want to save this repeated keypress. (Update: But only list the possible completions, it shouldn't automatically modify my actual prompt line even if there is only one option left.)

Is there any way to achieve such behaviour?

share|improve this question
    
You can get quite deep into customizing zsh's behavior. What should happen exactly? At the moment this question reads like you want the choices to be listed for every key press after the initial TAB, but that won't actually complete anything. Should every key press behave as if it was followed by a TAB? Bear in mind that this would mean quite a bit of backspacing for unintended completions. –  user112553 Mar 5 '12 at 9:34
    
@user112553 The first option: In that sense, it shouldn't actually behave like a repeated TAB. I just want the suggestion list to dynamically adjust. –  F30 Mar 5 '12 at 14:13

1 Answer 1

One way which might offer the solution you want, is incremental-complete-word:

zle -N incremental-complete-word
bindkey '^Xi' incremental-complete-word

This loads the funtion and binds it to Ctrl-X i. Now you can try it:

> k^Xi
incremental (complete): -no prefix-

In this example the letter k was typed, followed by Control-X i.

> kil
incremental (complete): kill       

I typed il and now there was one possible completion (kill). One could accept that and press enter.

> kill^D
incremental (complete): -no prefix-
- external command -
kill      killall   killall5

By typing Ctrl-D the zsh shows possible completions.

From zshcontrib(1):

incremental-complete-word
This allows incremental completion of a word. After starting this command, a list of completion choices can be shown after every character you type, which you can delete with ^H or DEL. Pressing return accepts the completion so far and returns you to normal editing (that is, the command line is not immediately executed). You can hit TAB to do normal completion, ^G to abort back to the state when you started, and ^D to list the matches.

share|improve this answer

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.