zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Marc Coquand <marcc0000@pm.me>
Cc: zsh-users@zsh.org
Subject: Re: How to have Zsh completion menu and use glob patterns + recursive search?
Date: Thu, 29 Jun 2023 17:44:17 -0700	[thread overview]
Message-ID: <CAH+w=7acJOqCJ8=YP9DbuWPjnwxUB0Z4Rr+JbkiV_W59S0eV8Q@mail.gmail.com> (raw)
In-Reply-To: <CTP52YIUNNY0.139TAZTO55SBV@Marcs-MBP>

On Thu, Jun 29, 2023 at 5:40 AM Marc Coquand <marcc0000@pm.me> wrote:
>
> I'd like to be able to do ./**/*file*<tab> and get a selectable list of all options available.

"do" that where?  Usually it would be after a command word such as
"ls" or "vi".  Each command may have a different completion function
that supplies contextual clues to adjust the results.

Presuming we're just talking about generic file completion context:

> I notice that if I remove all the previous options that I have enabled, ./**/*file*<tab> works but it expands to all available options.

That's because the default binding for the tab key is
"expand-or-complete".  You're seeing the results of the "expand" part,
which takes place before completion is attempted.  In many cases after
"compinit" you want to change the binding of tab to be
"complete-word".

bindkey $'\t' complete-word

> However, if I enable the completion list, ./**/*file*<tab> stops working and doesn't do anything.

You need the bindkey above (see the documention for _expand), followed
by at the least (other completer entries are possible)

zstyle ':completion:*' completer _expand _complete

The _expand completer takes the place of the expansion part of
"expand-or-complete" and (in effect) feeds the expansions back to the
completion menu instead of populating the command line directly.

You probably also want

zstyle :completion::expand::: tag-order expansions original

otherwise _expand will offer "all-expansions", that is, the "all
available options" set you didn't like, as one of the possible menu
choices, which if it is a large listing can have unexpected
side-effects on the display.


  reply	other threads:[~2023-06-30  0:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-29 12:40 Marc Coquand
2023-06-30  0:44 ` Bart Schaefer [this message]
2023-06-30  7:19   ` Marc Coquand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7acJOqCJ8=YP9DbuWPjnwxUB0Z4Rr+JbkiV_W59S0eV8Q@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=marcc0000@pm.me \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).