From: Sebastian Stark <sstark+zsh@mailbox.org>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: zsh-users@zsh.org
Subject: Re: Separate cdpath elements in path-directories completion
Date: Sun, 19 Feb 2023 11:02:17 +0100 [thread overview]
Message-ID: <20230219100217.f2mcniygwgbtxvwf@singold.localdomain> (raw)
In-Reply-To: <CAH+w=7bhjyXVgMb7esyg-1n0SbBAZogUrCVg34wFB64z3aUimg@mail.gmail.com>
Am Sonntag, den 19. Februar 2023 um 00:05 schrieb Bart Schaefer:
>On Sat, Feb 18, 2023 at 1:11 PM Sebastian Stark <sstark+zsh@mailbox.org> wrote:
>>
>> Is it possible to show a separate completion section for each element in
>> $cdpath?
>
>You would have to arrange that each directory's name becomes a tag
>(the "path-directories:" part in the alt= assignment) and call
>"_path_files -W" separately for each directory. There's no existing
>shortcut for this.
Thanks for showing me the right direction. I ended up with the
following, in case somebody wants that feature too. I can control the
behaviour by adding
"zstyle ':completion:*:directories' cdpath-sections true"
to my config.
--- /usr/share/zsh/functions/Completion/Zsh/_cd 2023-02-08 23:22:07.000000000 +0100
+++ .zfunc/_cd 2023-02-19 10:51:50.263265022 +0100
@@ -70,8 +70,15 @@
tmpcdpath=(${${(@)cdpath:#.}:#$PWD})
- (( $#tmpcdpath )) &&
- alt=( 'path-directories:directory in cdpath:_path_files -W tmpcdpath -/' )
+ if zstyle -t ":completion:${curcontext}:directories" cdpath-sections; then
+ local elem
+ for elem in $tmpcdpath; do
+ alt+=( "path-directories-$elem:$elem:_path_files -W $elem -/" )
+ done
+ else
+ (( $#tmpcdpath )) &&
+ alt=( 'path-directories:directory in cdpath:_path_files -W tmpcdpath -/' )
+ fi
# With cdablevars, we can complete foo as if ~foo/
if [[ -o cdablevars && -n "$PREFIX" && "$PREFIX" != <-> ]]; then
Sebastian
prev parent reply other threads:[~2023-02-19 10:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-18 21:10 Sebastian Stark
2023-02-18 23:03 ` Bart Schaefer
2023-02-19 10:02 ` Sebastian Stark [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=20230219100217.f2mcniygwgbtxvwf@singold.localdomain \
--to=sstark+zsh@mailbox.org \
--cc=schaefer@brasslantern.com \
--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).