zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: "Jörg Sommer" <joerg@jo-so.de>
Cc: zsh-workers@zsh.org
Subject: Re: File completion with git ls-files
Date: Sun, 7 Jan 2024 10:46:10 -0800	[thread overview]
Message-ID: <CAH+w=7YPKhNYNn1Q735tuyixLe4XP2Uvb9si=6L9fN7k8wu_9g@mail.gmail.com> (raw)
In-Reply-To: <ujth4vhk5oeyo2oq22tlwbnwzlw7um6xny5cnwr55dfvgsxlry@prk6w3ib3rbi>

On Sun, Jan 7, 2024 at 10:05 AM Jörg Sommer <joerg@jo-so.de> wrote:
>
> I am looking for a way to complete the full path to files in a subdirectory
> by its name. I would like to enter `less foo`, hit TAB (or a special short
> cut) and cycle through the list of `dir/subd-1/subd-2/foo…`,
> `dir2/abc/foo…`, `dir2/s1/s2/s3/foo`.

This is more along the lines of a zsh-users question, but something like this:

git-search-complete() {
  local f
  for f in ${(f)"$( git ls-files )"}
  do
    if [[ $f = */* ]]
    then
      compadd -f -P $f:h/ $f:t
    else
      compadd -f $f
    fi
  done
}
zle -C git-search-complete .menu-complete git-search-complete

Then bindkey git-search-complete to your preference.

This could pretty easily be made into an entry in your "completer"
zstyle to be invoked by TAB when nothing is found by earlier
completers.


      reply	other threads:[~2024-01-07 18:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-07 18:05 Jörg Sommer
2024-01-07 18:46 ` Bart Schaefer [this message]

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=7YPKhNYNn1Q735tuyixLe4XP2Uvb9si=6L9fN7k8wu_9g@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=joerg@jo-so.de \
    --cc=zsh-workers@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).