Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Assume there are three dirs: abc adc aec

I want to type cd dc, press Tab and get cd adc (trailing / is not important) completion.

Is it possible? What is the simplest way to achieve this behaviour?

I can move cursor to d inside dc and then press Tab, zsh will complete; but this is not convenient at all.

share|improve this question

In your ~/.zshrc:

  1. Make sure you're enabling compinit:

    autoload -U compinit
    compinit -i
  2. Enable tab-completion in-word:

    setopt complete_in_word
  3. Shift the cursor to the end of the word after tab-completion.

    setopt always_to_end

Those four lines (or even just [1] and [2]) were all I needed in an empty ~/.zshrc to enable this behaviour.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .