dirstack - builds a shell directory stack from a file of previously stored directories


  source dirstack


dirstack is a csh/tcsh script that builds a directory stack for a login shell from a directory file. A directory file in this context is a file that lists the previously stored directories names used by csh or tcsh.

dirstack uses the most recently used directory file that is considered "current". Current directory files are those directory files in the ~/.sessions directory that do not have the .save suffix. After using a current directory file, dirstack will rename the directory file so that it has the .save suffix.

The source'ing shell's starting directory is removed from the final stack of directories. This is done because dirstack is intended to mirror the list of directories it is reading, not to add to the existing directory stack.

This script should be sourced, rather than executed. Directory names that contain spaces are properly handled.

csh has a facility for saving a directory stack, but it is geared towards single-shell use. This script is intended for use in a windowing environment.


There are a number of requirements for using dirstack:


Copyright 2014 Wayne Morrison

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


Wayne Morrison,


oldjobs(1), ttymaint(1)