Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Dynamic named directories and completion
- X-seq: zsh-users 23163
- From: Vincent Bernat <bernat@xxxxxxxx>
- To: Scott Frazer <frazer.scott@xxxxxxxxx>
- Subject: Re: Dynamic named directories and completion
- Date: Fri, 23 Feb 2018 09:01:11 +0100
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed; d=luffy.cx; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=postfix; bh=T6N/ofzcthclFnqpiZviRHq76VA=; b=se0 dp6m4bChCTA84f6DcVQEzYs6zzBK9fb6iw4+RRKLeNJLNHzz1EQ5FtT5SSdWX/cC Hj12Ls71f92lWA1ckxa0HXg5SirY4RFByiduke/I2eYfXeNUU0fqN34tSKUpcgBt NXxWjfT72JsfUdm3G7FTSFlvC6aMiHyjz2B16csU=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=luffy.cx; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=postfix; b=DQAe921CC3VtPYmhudxm2LHRH58Rg MIX+Ukr33WazalltD6viDhtKdjsuV0k48JakEWPZbQ0cFEooH62SIAUn4dbZ+ifJ T4kSuDGyjy9/ZbfHG/rowLEfeSHCi+f14JD/b5D25VhX1iwL14kLgBjb+vQq2wad 4MV/+gnobXtlzg=
- In-reply-to: <p6nhj1$5nv$1@blaine.gmane.org> (Scott Frazer's message of "Thu, 22 Feb 2018 17:54:24 -0500")
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <p6nhj1$5nv$1@blaine.gmane.org>
❦ 22 février 2018 17:54 -0500, Scott Frazer <frazer.scott@xxxxxxxxx> :
> 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?
I don't see anything wrong in your code and for me, it works as you
expect (zsh 5.4.2). Does "echo ~[ccc]" returns the right value?
--
This was the most unkindest cut of all.
-- William Shakespeare, "Julius Caesar"
Messages sorted by:
Reverse Date,
Date,
Thread,
Author