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

Re: named directory expansion on strings



On Mar 13,  4:29am, Thorsten Kampe wrote:
}
} Is there a way to perform "named directory" expansion on strings?

Sort of.  See "print" in "man zshbuiltins" and look at the -D option.

} Something like "autonamedirs" and the "%~" in the prompt...
} 
} % file=/etc/foo
} % ETCDIR=/etc
} % echo `bar#!$whatever($file)`

I take it that the stuff in backticks is something that you just made up
to represent an arbitrary cryptic zsh incantation?

} ~ETCDIR/foo

You'd never get that in this particular example.  "ETCDIR" has six letters,
plus the tilde makes seven.  "/etc" has four letters.  Zsh always chooses
whichever one is shorter.

If you did

% setopt auto_name_dirs
% file=/etc/foo
% E=/etc
% print -D $file

Then you'd get

~E/foo

because ~E has only two letters.



Messages sorted by: Reverse Date, Date, Thread, Author