dirs built-in command for tcsh: Print the directory stack

Format

Description

dirs used alone prints the directory stack in the following format: The top of the stack is at the left and the first directory in the stack is the current directory. For example:
 > cd <========== # Change to home dir
 > pushd /bin <== # Change dir to /bin and add /bin to dir stack
 /bin ~
 > pushd /tmp <== # Change dir to /tmp and add /tmp to dir stack
 /tmp /bin ~
 > dirs <======== # Display current dir stack
 /tmp /bin ~
 > dirs -l <===== # Display in expanded (long) format
 /tmp /bin /u/erinf
 > dirs -v <===== # Display in verbose format
 0 /tmp
 1 /bin
 2 ~
 > popd <======== # Change dir back to /bin and remove /tmp from dir stack
 /bin ~
 >pwd
 /bin
Note:  dir=directory
 

Options

–l
Output is expanded explicitly to home or the path name of the home directory for the user.
-n
Entries are wrapped before they reach the edge of the screen.
-v
Entries are printed one per line, preceded by their stack positions.

If more than one of -n or -v is given, -v takes precedence.

-S
Saves the directory stack to file name as a series of cd and pushd commands.
-L
The tcsh shell sources file name, which is presumably a directory stack file saved by the -S option or the savedirs mechanism. In either case, dirsfile is used if file name is not given and ~/.cshdirs is used if dirsfile is unset.

Login shells do the equivalent of dirs -L on startup and, if savedirs is set, you should issue dirs -S before exiting. Because only ~/.tcshrc is normally sourced before ~/.cshdirs, dirsfile should be set in ~/.tcshrc instead of ~/.login.

–c
Clear the directory stack.

Related information

tcsh