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

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



On Jul 21, 2008, at 6:41 PM, Phil Pennock wrote:

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.

I think what I really meant to say is that I think it should be consistent. I.e., it should either never do it, or always do it (perhaps through a setting/option).

At least in my case I had been using my own custom prompt function that used $HOME (the abbreviation code stolen from fish) and I noticed I could use print -P '%~' instead of doing the tilde replacement myself. However, after switching to that, I noticed what seemed to be the random behavior of using a named directory. After looking at zsh's source code I realized it was using a cache and I had been populating the cache in some cases without realizing it.

Anyway, regardless of that, is there a way to populate the cache when I load zsh, and is there a way to disable named directory expansion for %~? Though I suppose I could just as well use "${PWD/$HOME/~}" in the latter case.

(Also, sorry for sending this twice. I meant to reply to the list as well.)



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