Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: possibly useful zsh_directory_name implementation



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