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

Re: problem with named directories over the net



On Mon, Jan 14, 2002 at 01:27:29PM +0000, Duncan Sinclair wrote:
> Hi,
> 
> Dominik writes:
> >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?
> 
> 
> In my .zshenv I have this code....
> 
> # Going for hack of the year award...
> case "$PWD" in
>     /tmp_mnt/*) cd '/tmp_mnt' '' ;;
>     /export/*)  cd '/export'  '' ;;
>     *) ;;
>   esac
> 
> It was put there to get around older Sun automounter difficulties...
> (It is no-longer necessary, but it does no harm...)
> 
> If you want to be really pro-active, you could try something like
> this in your precmd function...
> 
>   precmd() {
>     case "$PWD" in
>       /net/server/share/*) cd '/net/server/share' '' ;;
>       *) ;;
>     esac
>   }

Works like a charm - with a few minor modifications.  First, you
can put that in the chpwd function to have the code executed only
when the working directory changes.  Second, the slash before the
asterisk in the case value prevents that it works on the top
directory itself since PWD does not have the trailing slash for
directories.  I now use this script:

  chpwd ()
  {
    case "$PWD" in
      /net/server/share/home*)
        cd '/net/server/share' ''
        ;;
      /net/server/share/common*)
        cd '/net/server/share' ''
        ;;
      *)
        ;;
    esac
  }

Where "common" is a named directory pointing to
/net/server/share/common and /home is a symbolic link.


Bye

Dominik ^_^  ^_^

-- 
Dominik Vogt, email: d.vogt@xxxxxxxxxxx
LifeBits Aktiengesellschaft, Albrechtstr. 9, D-72072 Tuebingen
fon: ++49 (0) 7071/7965-0, fax: ++49 (0) 7071/7965-20



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