From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2078 invoked from network); 14 Jan 2002 16:41:05 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 14 Jan 2002 16:41:05 -0000 Received: (qmail 21267 invoked by alias); 14 Jan 2002 16:40:50 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 4589 Received: (qmail 21256 invoked from network); 14 Jan 2002 16:40:49 -0000 X-Authentication-Warning: erdbeere.lifebits.local: luthien set sender to d.vogt@lifebits.de using -f Date: Mon, 14 Jan 2002 17:40:39 +0100 From: Dominik Vogt To: zsh-users@sunsite.auc.dk Subject: Re: problem with named directories over the net Message-ID: <20020114174039.F633@lifebits.de> Reply-To: d.vogt@lifebits.de Mail-Followup-To: zsh-users@sunsite.auc.dk References: <20020111134158.F852@lifebits.de> <27644.1011014849@dis.strath.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.12i In-Reply-To: <27644.1011014849@dis.strath.ac.uk>; from sinclair@dis.strath.ac.uk on Mon, Jan 14, 2002 at 01:27:29PM +0000 X-Virus-Scanned: by AMaViS perl-11 X-Sender: 520008918237-0001@t-dialin.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@lifebits.de LifeBits Aktiengesellschaft, Albrechtstr. 9, D-72072 Tuebingen fon: ++49 (0) 7071/7965-0, fax: ++49 (0) 7071/7965-20