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

Re: problem with named directories over the net



Dominik Vogt wrote:
> I like to shorten my prompt by using '~' instead of the full path
> to my home directory.  For example:
> 
>   / $ cd ~/bin
>   ~/bin $
> 
> Now the problem occurs when I fire up mc.  Upon leaving mc, a
> script from the mc documentation cds into the current path and I
> get something like
> 
>   /net/server/share/home/luthien/bin $
> 
> as the prompt because this is where my home directory comes from.
> /home is a symbolic link to /net/server/share/home.  Any idea how
> I can prevent this?

You can generically prevent anything like this by altering HOME to the
resolved path in your .zshrc:

if [[ $PWD = $HOME(|/*) ]]; then
  newdir=${PWD##$HOME}
  HOME=$(cd $HOME && pwd -r || print $HOME)
  cd $HOME${newdir}
  unset newdir
else
  HOME=$(cd $HOME && pwd -r || print $HOME)
fi

This produces HOME=/net/server/share/home/luthien in your case.
That's a general case --- you can shorten the code if you assume a
particular form for $HOME before and after resolution.

If you want to keep inside the symbolic link, since it's mc that's
resolving the link and presenting zsh with it, and zsh can't tell if
there's a symbolic link pointing to the current directory, it looks like
you need to handle this case specially in mc somehow.  Obviously you can
replace /net/server/share/home with /home in the directory before changing
to it.

cd ${$(<"$MC")##/net/server/share}

What more are you looking for?

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 392070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************



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