zsh-users
 help / color / mirror / code / Atom feed
* accept-exact and current directory
@ 2015-09-13 18:12 Jesper Nygårds
  2015-09-13 20:49 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Jesper Nygårds @ 2015-09-13 18:12 UTC (permalink / raw)
  To: Zsh Users

[-- Attachment #1: Type: text/plain, Size: 1020 bytes --]

I use menu completion, and a while ago I found the accept-exact zstyle:

zstyle ':completion:*' accept-exact true

This works very well for me, as I find I often write the whole of a (short)
word, and then on reflex hit <tab> without really intending to do so.
Without the "accept-exact" zstyle, I often change what I wanted to write.

However, I recently discovered a problem with this. Suppose I want to
complete on some hidden file (i.e. beginning with a dot) in my home
directory. I write:

ls ~/.<tab>

Now, since accept-exact is active, zsh assumes that I mean '.' for current
directory, and completes with:

ls ~/./

since '.' is a directory. After that I have to manually remove the trailing
slash, and try to remember the first letter in the file I'm looking for.

Is there some way to specify that I never want '.' to match, as in the path
above and similar cases? I can't see a case where I would ever want to
write "/somepath/./" . Without a way to exclude '.', I guess I'll have to
stop using accept-exact.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: accept-exact and current directory
  2015-09-13 18:12 accept-exact and current directory Jesper Nygårds
@ 2015-09-13 20:49 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2015-09-13 20:49 UTC (permalink / raw)
  To: Zsh Users

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 */.)


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-09-13 20:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-13 18:12 accept-exact and current directory Jesper Nygårds
2015-09-13 20:49 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).