* problem with named directories over the net
@ 2002-01-11 12:41 Dominik Vogt
2002-01-11 12:55 ` Borsenkow Andrej
` (2 more replies)
0 siblings, 3 replies; 15+ messages in thread
From: Dominik Vogt @ 2002-01-11 12:41 UTC (permalink / raw)
To: zsh-users
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?
The function I start mc with looks like this:
------------------------ snip --------------------
# midnight commander (change dir after exit)
mc ()
{
local MC
MC=/tmp/mc$$-"$RANDOM"
if [ "$TERM" = xterm -o "$TERM" = rxvt ] ; then
/usr/bin/mc -a -c -d -u -x -P "$@" > "$MC"
else
/usr/bin/mc -a -c -d -u -P "$@" > "$MC"
fi
cd `cat "$MC"`
rm "$MC"
unset MC;
}
------------------------ snip --------------------
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
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: problem with named directories over the net
2002-01-11 12:41 problem with named directories over the net Dominik Vogt
@ 2002-01-11 12:55 ` Borsenkow Andrej
2002-01-11 14:28 ` Dominik Vogt
2002-01-11 13:05 ` Peter Stephenson
2002-01-14 13:27 ` Duncan Sinclair
2 siblings, 1 reply; 15+ messages in thread
From: Borsenkow Andrej @ 2002-01-11 12:55 UTC (permalink / raw)
To: d.vogt, zsh-users
>
> 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?
>
PS1="%~ %# "
Is it what you want?
-andrej
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: problem with named directories over the net
2002-01-11 12:41 problem with named directories over the net Dominik Vogt
2002-01-11 12:55 ` Borsenkow Andrej
@ 2002-01-11 13:05 ` Peter Stephenson
2002-01-14 13:27 ` Duncan Sinclair
2 siblings, 0 replies; 15+ messages in thread
From: Peter Stephenson @ 2002-01-11 13:05 UTC (permalink / raw)
To: zsh-users
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@csr.com> 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.
**********************************************************************
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: problem with named directories over the net
2002-01-11 12:55 ` Borsenkow Andrej
@ 2002-01-11 14:28 ` Dominik Vogt
2002-01-11 14:35 ` Borsenkow Andrej
` (2 more replies)
0 siblings, 3 replies; 15+ messages in thread
From: Dominik Vogt @ 2002-01-11 14:28 UTC (permalink / raw)
To: zsh-users
On Fri, Jan 11, 2002 at 03:55:48PM +0300, Borsenkow Andrej 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?
> >
>
> PS1="%~ %# "
>
> Is it what you want?
No, I already have that im my prompt. The problem is that only
"/home/luthien" is written as "~",
not "/net/server/share/home/luthien".
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
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: problem with named directories over the net
2002-01-11 14:28 ` Dominik Vogt
@ 2002-01-11 14:35 ` Borsenkow Andrej
2002-01-11 15:36 ` Dominik Vogt
2002-01-11 14:41 ` Zefram
2002-01-11 15:50 ` Bart Schaefer
2 siblings, 1 reply; 15+ messages in thread
From: Borsenkow Andrej @ 2002-01-11 14:35 UTC (permalink / raw)
To: d.vogt, zsh-users
> >
> > PS1="%~ %# "
> >
> > Is it what you want?
>
> No, I already have that im my prompt. The problem is that only
> "/home/luthien" is written as "~",
> not "/net/server/share/home/luthien".
>
Yes, I already realized I misunderstood the problem.
I wonder if zsh should resolve links when comparing paths. Is there
cases when somebody would like to treat link and its target differently?
-andrej
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: problem with named directories over the net
2002-01-11 14:28 ` Dominik Vogt
2002-01-11 14:35 ` Borsenkow Andrej
@ 2002-01-11 14:41 ` Zefram
2002-01-11 15:38 ` Bart Schaefer
2002-01-11 15:50 ` Bart Schaefer
2 siblings, 1 reply; 15+ messages in thread
From: Zefram @ 2002-01-11 14:41 UTC (permalink / raw)
To: zsh-users
Dominik Vogt wrote:
>"/home/luthien" is written as "~",
>not "/net/server/share/home/luthien".
What difference does the option CHASE_LINKS make for you? It should
give you a consistent resolution of the directory name, which should
be helpful.
-zefram
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: problem with named directories over the net
2002-01-11 14:35 ` Borsenkow Andrej
@ 2002-01-11 15:36 ` Dominik Vogt
0 siblings, 0 replies; 15+ messages in thread
From: Dominik Vogt @ 2002-01-11 15:36 UTC (permalink / raw)
To: zsh-users
On Fri, Jan 11, 2002 at 05:35:27PM +0300, Borsenkow Andrej wrote:
> > >
> > > PS1="%~ %# "
> > >
> > > Is it what you want?
> >
> > No, I already have that im my prompt. The problem is that only
> > "/home/luthien" is written as "~",
> > not "/net/server/share/home/luthien".
> >
>
> Yes, I already realized I misunderstood the problem.
>
> I wonder if zsh should resolve links when comparing paths. Is there
> cases when somebody would like to treat link and its target differently?
I think zsh can't even know that there is a link from /home to
/net ... I'd have to specify a list of directories that are shown
with the same name in the prompt.
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
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: problem with named directories over the net
2002-01-11 14:41 ` Zefram
@ 2002-01-11 15:38 ` Bart Schaefer
0 siblings, 0 replies; 15+ messages in thread
From: Bart Schaefer @ 2002-01-11 15:38 UTC (permalink / raw)
To: zsh-users
On Jan 11, 2:41pm, Zefram wrote:
} Subject: Re: problem with named directories over the net
}
} Dominik Vogt wrote:
} >"/home/luthien" is written as "~",
} >not "/net/server/share/home/luthien".
}
} What difference does the option CHASE_LINKS make for you?
I just tried that, and it makes neither one be written as tilde, unless
you also reassign HOME to refer to the chased path, in which case it
makes both be rewritten as tilde.
So something like
setopt CHASE_LINKS
cd $HOME
export HOME=$PWD
should produce the desired effect, although CHASE_LINKS might have some
other side effects you don't like.
I seem to recall that some flavors of automounter don't work right when
you refer to a file by its real automount path and not via the automount
directory.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: problem with named directories over the net
2002-01-11 14:28 ` Dominik Vogt
2002-01-11 14:35 ` Borsenkow Andrej
2002-01-11 14:41 ` Zefram
@ 2002-01-11 15:50 ` Bart Schaefer
2002-01-11 18:51 ` Dominik Vogt
2 siblings, 1 reply; 15+ messages in thread
From: Bart Schaefer @ 2002-01-11 15:50 UTC (permalink / raw)
To: d.vogt, zsh-users
On Jan 11, 3:28pm, Dominik Vogt wrote:
} Subject: Re: problem with named directories over the net
}
} > PS1="%~ %# "
}
} No, I already have that im my prompt. The problem is that only
} "/home/luthien" is written as "~",
} not "/net/server/share/home/luthien".
My "stupid zsh tricks" entry for the month:
hash -d /=/net/server/share/home/luthien
This causes zsh to write /net/server/share/home/luthien as tilde-slash,
which is pretty nearly indistinguishable from tilde. It means that
sub-directories of your home directory will sometimes be displayed as
~//subdir, but maybe you can live with that.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: problem with named directories over the net
2002-01-11 15:50 ` Bart Schaefer
@ 2002-01-11 18:51 ` Dominik Vogt
0 siblings, 0 replies; 15+ messages in thread
From: Dominik Vogt @ 2002-01-11 18:51 UTC (permalink / raw)
To: zsh-users
On Fri, Jan 11, 2002 at 03:50:07PM +0000, Bart Schaefer wrote:
> On Jan 11, 3:28pm, Dominik Vogt wrote:
> } Subject: Re: problem with named directories over the net
> }
> } > PS1="%~ %# "
> }
> } No, I already have that im my prompt. The problem is that only
> } "/home/luthien" is written as "~",
> } not "/net/server/share/home/luthien".
>
> My "stupid zsh tricks" entry for the month:
>
> hash -d /=/net/server/share/home/luthien
>
> This causes zsh to write /net/server/share/home/luthien as tilde-slash,
> which is pretty nearly indistinguishable from tilde.
> It means that
> sub-directories of your home directory will sometimes be displayed as
> ~//subdir, but maybe you can live with that.
Easily. Thanks a lot!
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
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: problem with named directories over the net
2002-01-11 12:41 problem with named directories over the net Dominik Vogt
2002-01-11 12:55 ` Borsenkow Andrej
2002-01-11 13:05 ` Peter Stephenson
@ 2002-01-14 13:27 ` Duncan Sinclair
2002-01-14 16:40 ` Dominik Vogt
2 siblings, 1 reply; 15+ messages in thread
From: Duncan Sinclair @ 2002-01-14 13:27 UTC (permalink / raw)
To: d.vogt; +Cc: zsh-users
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
}
No idea if it works...
Good luck!
Duncan.
PS> Solutions involving CHASE_LINKS are _evil_!!!
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: problem with named directories over the net
2002-01-14 13:27 ` Duncan Sinclair
@ 2002-01-14 16:40 ` Dominik Vogt
2002-01-14 18:11 ` Bart Schaefer
0 siblings, 1 reply; 15+ messages in thread
From: Dominik Vogt @ 2002-01-14 16:40 UTC (permalink / raw)
To: zsh-users
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
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: problem with named directories over the net
2002-01-14 16:40 ` Dominik Vogt
@ 2002-01-14 18:11 ` Bart Schaefer
2002-01-15 10:53 ` Dominik Vogt
0 siblings, 1 reply; 15+ messages in thread
From: Bart Schaefer @ 2002-01-14 18:11 UTC (permalink / raw)
To: d.vogt, zsh-users
On Jan 14, 5:40pm, Dominik Vogt wrote:
} Subject: Re: problem with named directories over the net
}
} 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.
I had been about to suggest that myself, but if you ever happen to
'setopt chaselinks' you could end up with an infinite loop on your
hands, so I didn't. Also, if it's in chpwd it won't get executed
the first time a new shell starts up, which might make a difference
in a few rare cases.
Of course you can insert a call to chpwd at the end of your .zshrc, and if
you use the zsh/parameter module you could prevent the infinite loop with:
chpwd ()
{
[[ $funcstack == chpwd*chpwd* ]] && return
# ... etc. ...
}
} 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
} }
Is it really the case that only `home' and `common' are automounted?
Anyway, having an empty *) fallthrough is redundant. Why not just:
chpwd ()
{
[[ $PWD == /net/server/share/* ]] && cd /net/server/share ''
}
(plus possible loop protection per above)?
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: problem with named directories over the net
2002-01-14 18:11 ` Bart Schaefer
@ 2002-01-15 10:53 ` Dominik Vogt
2002-01-15 17:59 ` Bart Schaefer
0 siblings, 1 reply; 15+ messages in thread
From: Dominik Vogt @ 2002-01-15 10:53 UTC (permalink / raw)
To: zsh-users
On Mon, Jan 14, 2002 at 06:11:32PM +0000, Bart Schaefer wrote:
> On Jan 14, 5:40pm, Dominik Vogt wrote:
> } Subject: Re: problem with named directories over the net
> }
> } 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.
>
> I had been about to suggest that myself, but if you ever happen to
> 'setopt chaselinks' you could end up with an infinite loop on your
> hands, so I didn't.
In fact I got that loop at some point when writing the function
and switched to precmd so that I don't have to think about it.
> Also, if it's in chpwd it won't get executed
> the first time a new shell starts up, which might make a difference
> in a few rare cases.
>
> Of course you can insert a call to chpwd at the end of your .zshrc,
That's how I've been doing it for ages to set the xterm title.
> and if
> you use the zsh/parameter module you could prevent the infinite loop with:
Nope, I'm still using the zsh that came with SuSE 7.1 at work (3.1.9).
>
> chpwd ()
> {
> [[ $funcstack == chpwd*chpwd* ]] && return
> # ... etc. ...
> }
>
> } 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
> } }
>
> Is it really the case that only `home' and `common' are automounted?
> Anyway, having an empty *) fallthrough is redundant. Why not just:
>
> chpwd ()
> {
> [[ $PWD == /net/server/share/* ]] && cd /net/server/share ''
> }
>
> (plus possible loop protection per above)?
I can't use this approach because there are some directories on
the share that are not remapped to /. Some are mapped to named
directories that not necessarily have the same name (obviously, I
can't give the tmp directory on the share the name 'tmp').
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
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: problem with named directories over the net
2002-01-15 10:53 ` Dominik Vogt
@ 2002-01-15 17:59 ` Bart Schaefer
0 siblings, 0 replies; 15+ messages in thread
From: Bart Schaefer @ 2002-01-15 17:59 UTC (permalink / raw)
To: d.vogt, zsh-users
On Jan 15, 11:53am, Dominik Vogt wrote:
} Subject: Re: problem with named directories over the net
}
} > and if
} > you use the zsh/parameter module you could prevent the infinite loop with:
}
} Nope, I'm still using the zsh that came with SuSE 7.1 at work (3.1.9).
3.1.9 has the zsh/parameter module and the funcstack parameter therein.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2002-01-15 17:59 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-11 12:41 problem with named directories over the net Dominik Vogt
2002-01-11 12:55 ` Borsenkow Andrej
2002-01-11 14:28 ` Dominik Vogt
2002-01-11 14:35 ` Borsenkow Andrej
2002-01-11 15:36 ` Dominik Vogt
2002-01-11 14:41 ` Zefram
2002-01-11 15:38 ` Bart Schaefer
2002-01-11 15:50 ` Bart Schaefer
2002-01-11 18:51 ` Dominik Vogt
2002-01-11 13:05 ` Peter Stephenson
2002-01-14 13:27 ` Duncan Sinclair
2002-01-14 16:40 ` Dominik Vogt
2002-01-14 18:11 ` Bart Schaefer
2002-01-15 10:53 ` Dominik Vogt
2002-01-15 17:59 ` Bart Schaefer
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).