Using the directory stack like !-2:3 in csh

Karl Kleinpaste karl at cheops.cis.ohio-state.edu
Thu May 19 05:23:22 AEST 1988


Tcsh provides for direct access to the directory stack with a
modification to the syntax for filenames.  From the tcsh man page,

14. DIRECTORY STACK ELEMENT ACCESS
     Tcsh will now allow the user to access all elements in the
     directory stack directly.  The syntax "=<digit>" is recog-
     nized by tcsh as indicating a particular directory in the
     stack.  (This works for the file/command name recognition as
     well.) This syntax is analogous to the ~ syntax for access
     to users' home directories.  The stack is viewed as zero-
     based, i.e., =0 is the same as $cwd, which is the same as
     ".".  As a special case, the string "=-" is recognized as
     indicating the last directory in the stack.  Thus,

          > dirs
          /usr/net/bin /usr/spool/uucp /usr/accts/sys
          > echo =2
          /usr/accts/sys
          > ls -l =1/LOGFILE
          -rw-r--r-- 1 uucp   2594 Jan 19 09:09 /usr/spool/uucp/LOGFILE
          > echo =-/.cs*
          /usr/accts/sys/.cshrc
          > echo =4
          Not that many dir stack entries.
          >

     Tcsh will complain if you ask for a directory stack item
     which does not exist.

I put this to use by having, in my .cshrc, the lines
	pushd /usr/spool/uucp
	pushd /u/osu/src
	pushd +2
Thereafter, I can use =1 to get at things under our source area, and
=- to check on the state of UUCP things.

Tcsh was distributed over comp.sources.unix a while back.  Check a
nearby archive site.

--Karl



More information about the Comp.unix.wizards mailing list