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

Re: Bug with named dirs in prompt expansion



On 2013-07-26 at 20:58 +0200, Manuel Presnitz wrote:
> is it just me, or is there a bug in the "%~" prompt expansion:

It's the documented, specified behaviour.  See zshexpn(1):

----------------------------8< cut here >8------------------------------
   Static named directories
[...]
       In  certain  circumstances  (in  prompts, for instance), when the shell
       prints a path, the path is checked to see if it has a  named  directory
       as  its  prefix.  If so, then the prefix portion is replaced with a `~'
       followed by the name of the directory.  The shortest way  of  referring
       to  the  directory is used, with ties broken in favour of using a named
       directory, except when the directory is / itself.  The parameters  $PWD
       and $OLDPWD are never abbreviated in this fashion.
----------------------------8< cut here >8------------------------------

> I would expect that after ": ~fooo" the prompt changes to "~fooo>", but it doesn't.

The idea of %~ is to find the shortest available name, for a condensed
representation so as to concisely convey to the user where they are.

> this issue was originally raised here: http://superuser.com/q/624603/195224

I've posted a reply.

-Phil



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