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

Re: Tilde (%~) prompt expansion inconsistent with named directories?



On 2008-07-21 at 18:18 -0400, dackz wrote:
> I'm guessing this has to do with the named directory cache not being  
> populated. Shouldn't the expansion of %~ populate it automatically?

Debatable.  Arguably the setting of a prompt shouldn't trigger
potentially large amounts of work (reading in the list of users from
LDAP, for instance, with >10k users).

There are arguments either way.

> Also, how is a directory determined to be named in prompt expansion?  

The shortest match wins.

> If I run "cd ~www-data", "print -P '%~'" prints /var/www instead of  
> ~www-data. I actually prefer this behavior, but I'm wondering how zsh  
> makes the distinction in that case.

/var/www is the same length as www-data and shorter than ~www-data; zsh
will take the shortest match.  If ~name is the same length or shorter
than /path then ~name will be used.

It's actually a complete scan through the entire list of all known
names, searching for the one with the "best" difference in length.

-Phil



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