I have several files in my test directory that all start with 'test_'. I frequently use autocomplete to specify one of these files to edit or run. When I press tab to autocomplete, zsh correctly fills in 'test_' but then moves the cursor back one letter to between the 't' and '_'. I want to be able to type in the first distinguishing letter(s) of the file I want so I can press tab again to complete the full filename, but I have to press right arrow every time to get to where I can do that.

How do I get zsh to stop backspacing like that?

  • Please try if the behavior is the same when you start a ZSH session via zsh -f, i.e. without sourcing custom files. – mpy Jul 7 '13 at 16:22
  • It sounds like zsh is moving the cursor to the first ambiguous character. Perhaps test this behaviour in a new directory containing exactly two files: test_a and test_b, for example. If this doesn't solve it, I have the behaviour you're desiring - we can compare zsh options (or read the man pages ;)). – simont Jul 12 '13 at 13:51
  • Apologies for a long delay responding, just got back from vacay :) I just tried and it does NOT happen when I start with zsh -f. It tab-completes to 'test' and then stops. What would that narrow it down to? – scanny Jul 16 '13 at 7:28
  • 1
    zsh -f starts a shell withOUT reading any of your configuration files. Everything is at default value. So this narrows down the problem to your configuration ;-) you either did something funny with completion styles or you are using oh-my-zsh (the later is an endless source of questions about broken default behavior). – Francisco Jul 16 '13 at 14:03
  • I have nothing to add to @Francisco 's answer. Just start a clean ` zsh -f, take your ~/.zshrc` and execute a line after another until the problem occurs. Especially lines with compdef (but you shouldn't use that as it is outdated) or zstyle are likely to mess something up. [Btw. to notify a user directly, you need to include @username in you comment -- it was just by chance I visited this page again.] – mpy Jul 17 '13 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.