zsh-users
 help / color / mirror / code / Atom feed
* Dynamic named directories and completion
@ 2018-02-22 22:54 Scott Frazer
  2018-02-23  0:29 ` [RFC PATCH] _path_files: teach zsh_directory_name Takeshi Banse
  2018-02-23  8:01 ` Dynamic named directories and completion Vincent Bernat
  0 siblings, 2 replies; 19+ messages in thread
From: Scott Frazer @ 2018-02-22 22:54 UTC (permalink / raw)
  To: zsh-users

I'm trying to use dynamic named directories and have subsequent completion work.

Here is my (perhaps naive) attempt:

zsh_directory_name ()
{
     emulate -L zsh
     setopt extendedglob
     local -a seg;
     seg=(${(s:/:)PWD%/*})
     if [[ $1 = n ]]; then
         typeset -ga reply
         reply=( /${(j:/:)seg[1,(I)$2]} )
     elif [[ $1 = c ]]; then
         local expl
         _wanted values expl 'parent dirs' compadd -S\] -a seg
     else
         return 1
     fi
     return 0
}

Suppose I am in directory /aaa/bbb/ccc/ddd/eee and want to go up to directory
ccc and then down into another directory.  If I do:

cd ~[c<TAB>

it correctly completes to:

cd ~[ccc]

If I hit enter at this point I go to /aaa/bbb/ccc.  So far so good.  If I
try to start completion, like so:

cd ~[ccc]/<TAB>

zsh doesn't give me options for directories under ccc, it thinks '/' is
the command I'm trying to complete.  Is there a way to make this work?

Thanks,
Scott



^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2018-02-26 21:23 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-22 22:54 Dynamic named directories and completion Scott Frazer
2018-02-23  0:29 ` [RFC PATCH] _path_files: teach zsh_directory_name Takeshi Banse
2018-02-23  1:19   ` _path_files: fix copy paste error Takeshi Banse
2018-02-23  1:30   ` _path_files: fix copy paste error (2/2) Takeshi Banse
2018-02-23  8:01 ` Dynamic named directories and completion Vincent Bernat
2018-02-23 14:41   ` Scott Frazer
2018-02-23 15:02     ` Takeshi Banse
2018-02-23 14:42   ` Scott Frazer
2018-02-24 19:34     ` Peter Stephenson
2018-02-24 19:49       ` Mikael Magnusson
2018-02-24 20:12         ` Peter Stephenson
2018-02-26 14:31           ` Scott Frazer
2018-02-26 13:53       ` Scott Frazer
2018-02-26 14:47         ` Peter Stephenson
2018-02-26 16:44           ` Scott Frazer
2018-02-26 20:08             ` Peter Stephenson
2018-02-26 21:22               ` Peter Stephenson
2018-02-26 17:49           ` Mikael Magnusson
2018-02-26 17:55             ` Peter Stephenson

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).