Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1+some 2/3/84; site dual.UUCP Path: utzoo!linus!decvax!decwrl!dual!mats From: mats@dual.UUCP (Mats Wichmann) Newsgroups: net.unix Subject: Re: New uses for csh Message-ID: <619@dual.UUCP> Date: Mon, 25-Jun-84 18:23:41 EDT Article-I.D.: dual.619 Posted: Mon Jun 25 18:23:41 1984 Date-Received: Wed, 27-Jun-84 03:11:38 EDT References: <1403@proper.UUCP> Organization: Dual Systems, Berkeley, CA Lines: 42 Keywords: csh,source,alias RE: Gordon's neato implementation of pushd/popd for csh's that don't have them.... >> [in my .cshrc]: >> alias popd 'set argv = (\!*) ; source ~/csh/popd' >> alias pushd 'set argv = (\!*) ; source ~/csh/pushd' >> [~/csh/popd]: >> if (! $?_dirstack || $#_dirstack < 1) then >> echo "popd: Directory stack empty." >> else >> chdir $_dirstack[1] >> echo $_dirstack >> shift _dirstack >> endif >> [~/csh/pushd]: >> if ($#argv != 1) then >> echo "pushd: Arg count." >> else >> if (! $?_dirstack) set $_dirstack = () >> set _dirstack = (`pwd` $_dirstack) >> chdir $argv >> echo $argv $_dirstack >> endif I am not trying to criticise the intent of the article, which was to show a method for fudging more complex alias commands. However, the specific example used can be done more quickly, although it is not as complete an emulation... Try this (all in your .cshrc) if (! $?_d ) set _d = () alias pushd set _d = \(\`pwd\` \$_d\) \; cd \!\* alias popd cd \$_d\[1\] \; echo \$_d\[1\] : \; shift _d Avoids opening an extra file each time for the source, although it has a less elegant error recovery...I use it quite a bit when jumping around the system. Mats