Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: change behaviour of command line completion



On Wed, 27 May 2015 13:36:56 +0200
ruud grosmann <r.grosmann@xxxxxxxxx> wrote:
> In the old situation, when I was in a directory with only one file,
> 'example.txt' and I typed 'ls x<TAB>', no completion followed. Because
> no files start with an 'x'.
> But now, zsh happily changes the x to 'example.txt', because the x is
> in 'example.txt'. I rather don't want this behaviour, but I cannot
> find in the documentation of the options anything that describes this.

I'm assuming ohmyzsh uses the new completion system...  I have no idea
about ohmyzsh so I'm referring to the underlying shell to look for what
might be causing it.

This could be various things...


1. Approximate completion.  In other words, it's correcting what you
type and then trying to complete that.  So it thinks you "mistyped" by
omitting the "e" from "example.txt".

Do

  zstyle -L | grep -w completer

and look for something like:

  zstyle ':completion:*' completer _oldlist _expand _user_expand _complete _ignored _approximate

(This is mine, not ohmyzsh.)

If you see that "_approximate" (or also "_correct") you want to remove
those.  Using exactly the same line with that word or those words
removed will do the trick (the output in that form gives you a valid
command line you can put in .zshrc).  In this case, for example:

  zstyle ':completion:*' completer _oldlist _expand _user_expand _complete _ignored


2. Matcher control.  This allows you to update the rules that compare
what's on the command line with the trial matches.  This is probably
less likely, but it's certainly possible to set the sehll up like this.

Do

  zstyle -L | grep matcher-list

and look for something like:

  zstyle ':completion:*' matcher-list '' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} r:|[[:punct:]]=* r:|=*'

As matcher control is complicated, the simplest thing to do is remove
arguments from the end and enter the corresponding line until the
problem goes away.  Put very briefly, things like 'r:|=*' and 'l:|=*'
are what might be causing the problem as they're allowing the completion
system to add anything at one end or other of the string.  Obviously,
adding things at the end isn't usually a problem so I'd worry more about
things looking like 'l:|=*'.


Hope that's enough to track it down.

pws



Messages sorted by: Reverse Date, Date, Thread, Author