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

Re: Named directories

On Mon, 21 Feb 2005, Mika Seppänen wrote:

> If my homedir is /home/foo and I have named directory:
> work=/home/foo/bar
> Then if I switch to that dir (cd work), %~ expands to ~/bar. Is there any way
> to make it expand to ~work?

One thing that no one has mentioned in this thread is that %~ will always 
expand to the shortest possible string.

Thus, given


you'll always see ~two because "two" is shorter than "/bin".  Even if you 
"unset two", you'll never see ~three because both "/bin" and "four" are 
shorter than "three".  Because ~/bin and ~four are of equal length, what 
you see is (I believe) dependent on hash table ordering, and therefore 
unpredictable (though it should always be consistent).

Hey, PWS and the UTF-8 gang:  If "bin" were in fact a name consisting of
three wide characters, i.e., they display as three characters but occupy
6 or more bytes, would the prompt code treat ~three as a shorter string
for purposes of the %~ expansion?

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