🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #1619

Re: Csh question: Doing cd .. from a symbolically linked directory

#1619
From: Maarten Litmaath
Date: Thu, 25 Oct 1990 19:08
26 lines
1613 bytes
In article <KIVINEN.90Oct25125016@deathstar.hut.fi>,
	kivinen@cs.hut.fi (Tero Kivinen) writes:
)In article <JERRY.90Oct24110101@sky.slhisc.uucp>
)	jerry@slhisc.uucp (Jerry Liebelson) writes:
)>      Is there a way to set things in the csh such that when I do the cd ..
)>    from /tmp/c, I will end up in /tmp and not in /tmp/a?
)
)Try alias .. 'cd /$cwd:h' in your .cshrc, and then typing .. works.
)This will work in csh or in tcsh.

But that doesn't deal nicely with `cd ../../foo/bar'...
Following is a solution that does _and_ is completely builtin!
Piece of cake right?  :-)

--------------------cut here--------------------
alias	cd	'set tmp=(\!*); eval cd$#tmp $cwd \!*/. ../ ~; echo $cwd'
alias	cd0	'chdir \!$'
alias	cd1	'if (x\!:2 !~ x../*) set status=1'\
		'&& eval cd2 /\!^:h \!:2-:s-../--'\
		'|| chdir \!:2'
alias	cd2	'if (x\!:2 !~ x../*) set status=1'\
		'&& eval cd2 /\!^:h \!:2*:s-../--'\
		'|| chdir \!^/\!:2'
--------------------cut here--------------------
--
Waiting for this to work: cat /internet/cs.vu.nl/finger/maart
Technical Details
Message-ID: <8049@star.cs.vu.nl>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcsun!hp4nl!star.cs.vu.nl!maart
References: <JERRY.90Oct24110101@sky.slhisc.uucp> <KIVINEN.90Oct25125016@deathstar.hut.fi>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcsun!hp4nl!star.cs.vu.nl!maart
From: maart@cs.vu.nl (Maarten Litmaath)
Newsgroups: comp.unix.shell
Subject: Re: Csh question: Doing cd .. from a symbolically linked directory
Message-ID: <8049@star.cs.vu.nl>
Date: 25 Oct 90 19:08:23 GMT
References: <JERRY.90Oct24110101@sky.slhisc.uucp> <KIVINEN.90Oct25125016@deathstar.hut.fi>
Sender: news@cs.vu.nl
Reply-To: maart@cs.vu.nl (Maarten Litmaath)
Distribution: comp.unix.shell
Organization: VU Dept. of Computer Science, Amsterdam, The Netherlands
Lines: 26