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

Re: accept-exact and current directory

On Sep 13,  8:12pm, Jesper Nygards wrote:
} zstyle ':completion:*' accept-exact true
} ls ~/.<tab>
} Now, since accept-exact is active, zsh assumes that I mean '.' for current
} directory, and completes with:
} ls ~/./
} Is there some way to specify that I never want '.' to match, as in the path
} above and similar cases?

The doc for accept-exact says:

     When completing pathnames (where the tag used is `paths') this
     style accepts any number of patterns as the value in addition to
     the boolean values.  Pathnames matching one of these patterns will
     be accepted immediately even if the command line contains some
     more partially typed pathname components and these match no file
     under the directory accepted.

The part about "... even if ... these match no file" is a little confusing,
and in fact I can't come up with a case where it applies.  Maybe PWS or
Oliver can disentangle Sven's non-native English here.  Anyway, the point
is to come up with patterns that don't match a trailing dot:

    zstyle ':completion:*:paths' accept-exact '[^.]' '^(*/.)'

(remember these are string-match patterns, not globs, although they
share syntax, and that completion always uses extendedglob, so ^(*/.)
to strings not matching */.)

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