Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: File completion with git ls-files
- X-seq: zsh-workers 52470
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Jörg Sommer <joerg@xxxxxxxx>
- Cc: zsh-workers@xxxxxxx
- Subject: Re: File completion with git ls-files
- Date: Sun, 7 Jan 2024 10:46:10 -0800
- Archived-at: <https://zsh.org/workers/52470>
- In-reply-to: <ujth4vhk5oeyo2oq22tlwbnwzlw7um6xny5cnwr55dfvgsxlry@prk6w3ib3rbi>
- List-id: <zsh-workers.zsh.org>
- References: <ujth4vhk5oeyo2oq22tlwbnwzlw7um6xny5cnwr55dfvgsxlry@prk6w3ib3rbi>
On Sun, Jan 7, 2024 at 10:05 AM Jörg Sommer <joerg@xxxxxxxx> 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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author