Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Separate cdpath elements in path-directories completion
- X-seq: zsh-users 28948
- From: Sebastian Stark <sstark+zsh@xxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Cc: zsh-users@xxxxxxx
- Subject: Re: Separate cdpath elements in path-directories completion
- Date: Sun, 19 Feb 2023 11:02:17 +0100
- Archived-at: <https://zsh.org/users/28948>
- In-reply-to: <CAH+w=7bhjyXVgMb7esyg-1n0SbBAZogUrCVg34wFB64z3aUimg@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- Mail-followup-to: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, zsh-users@xxxxxxx
- References: <20230218211046.vj3p4k7y6uraytpo@singold.localdomain> <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@xxxxxxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author