When working in the Terminal, I often have to change back and forth between several directories. The tcsh shell has built-in capabilities to help with this: 'push' and 'pop' can be used instead of 'cd' when changing directories. With 'push' and 'pop', you get a stack of directories that makes it a bit easier for going back and forth. But this is not so useful if you have a more random pattern of directory use: you go here, then you go somewhere else, ... and of course, you have to remember to use 'push' and 'pop' instead of 'cd'. Often you find yourself having to type in a long directory path (but filename completion via Tab helps a lot here). So what I find convenient is the following facility which allows you to give short mnemonic names to directories and then you can use these names of your own choosing with 'cd' .
Read the rest of the article for the how-to...
First I'll show you how to use it (via examples) and then I'll show you how to implement it via a few aliases.
Suppose you find yourself frequently going to the directory /Users/fred/Documents/Projects/Acme. When you are in that directory, you issue the command:
% save acmeThis assigns "acme" as your own private short name for the directory you are in. Then, later on, when you are in some other (far-away) directory, you can go back to the Acme directory by issuing the command:
% cd acmeAfter a while, you may have accumulated a number of these short names for directories and they will serve as a memory aid. Suppose you forget where the preferences files are kept and you know that you had saved a short name for this directory, but you forget what it was. You issue the command...
% show... and you will get a list of all the short names and their full-path equivalents. Note: the short names you supply via the 'save' command must be one word (no spaces or punctuation).
% touch ~/.dirs
# The following aliases (save & show) are for saving frequently used directories[NOTE: Enter the "save" alias as one line; it's been broken here for readability]
# You can save a directory using an abbreviation of your choosing. Eg. save ms
# You can subsequently move to one of the saved directories by using cd with
# the abbreviation you choose. Eg. cd ms (Note that no '$' is necessary.)
alias save 'sed "/set \!$/d" ~/.dirs > ~/.dirs1; \mv ~/.dirs1 ~/.dirs; echo
set \!* = \"`pwd`\" >> ~/.dirs; source ~/.dirs'
alias sdirs 'source ~/.dirs'
alias show 'cat ~/.dirs'
# source the ~/.dirs file so that we get the previously set up variables
if ( -f ~/.dirs ) source ~/.dirs
% cp file1 file2 file3 $acmeHere the $ is necessary since (unlike 'cd') the 'cp' command does not automatically look for shell variables.
Mac OS X Hints
http://hints.macworld.com/article.php?story=20020716005123797