Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: possibly useful zsh_directory_name implementation
- X-seq: zsh-users 15859
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: possibly useful zsh_directory_name implementation
- Date: Fri, 11 Mar 2011 02:15:34 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=J/3ugX1k1l/zbqciPgo+yNltsxGjEeOBQ2zXAslEPMM=; b=my6eoj5Nlw5iL+h6ufNxmwAMJnE2trF1vvX81V7KffIk8WW4SMvqhG/ZNt7rhV1AyY g6LUuOYcG0x6nQ0FEjtQyiQ28M9i7tjswxOr0VyaoUQiLMVXgugkY3bbuuE+o74FEKlP IRmwii/5kgjMISbWL/giDTvj+ffemdBl6K9bU=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=l8FojxcOx99huLQUcJMYV440Bx1Nfoi2kamNLrZJLzmlDM8ftGLQLb8HwsCVon5cSt qJSmn702KDXuRwaoMoKmD8tJ5dp500Nnpr8/vht+phBDnhmciH/nXgwj1J2SWe600I3w NzmVwZhC/bzU7ojjI6Eec44WBfk10lPz7R8rs=
- In-reply-to: <AANLkTin+cCxFRYtwZXGSUWyLjfe7NV-eDx1mcS9sSau0@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <AANLkTin+cCxFRYtwZXGSUWyLjfe7NV-eDx1mcS9sSau0@mail.gmail.com>
On 11 March 2011 02:06, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> function zsh_directory_name () {
> case $1 in
> n)
> case $2 in
> /*)
> reply=( /${(j:/:)${(s:/:)PWD}[1,(er)${2[2,-1]}]} )
> ;;
> .*)
> reply=( (../)##${2[2,-1]}([1]) )
> ;;
> esac
> ;;
> c)
> local types vals description
> types=( '.:children of parent directories' '/:pwd segment' )
> case $PREFIX in
> '')
> vals=( $types )
> _describe 'dynamic dir type' vals -V dynamic-dirs -o -S ''
> ;;
> .*)
> vals=( (../)##*~(../)##$PWD:t(/:t) )
> ;|
> /*)
> vals=( "${(@)${(s:/:)PWD}[1,-2]}" )
> ;|
> *)
> _wanted -V dynamic-dirs expl
> ${${types[(r)$PREFIX[1]*]}[3,-1]} compadd -P $PREFIX[1] -qQS / -d vals
> ${(q)^vals}\]
These three lines should be one line, silly email.
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author