|
|
||||
|
The CDPATH environment variable defines additional locations to be searched when you type the cd command. When you type cd A, cd will look for A in the current directory. If you define the CDPATH environment variable which consists of a list of directories, cd will look for A in the current directory and if it is not found, the search continues in the directories defined in CDPATH, from left to right, stopping at the first place where it is found. Your working directory is then switched to A. For a concise explanation, log into the Fulton domain and type man cd. |
||||
|
You can define the CDPATH variable to make it easier to navigate through your folders when you are using the command line. You can type short direct names instead of long path names. This is especially useful when you need to access the folders of an alien domain. However, you cannot make use of file name completion or wildcards; in other words you need to type the entire folder name. |
||||
|
|
Examples: The following makes use of the file structure shown on the left. The root is /, so the first folder is /A, the second is /A/a, the third is /A/a/1 and the last is /C. CDPATH is defined to include three directories: /A/b, /A. and /B in this order. The variable $HOME has the value /B. Thus, if the current working directory is $1 and you type cd $2, the working directory will be changed to $3 if CDPATH is defined or to $4 if it is not. |
|||
|
|
|
|
|
|
|
/B |
1 |
/B/1 |
/B/1 |
|
|
/B |
a |
/A/a |
/B (no change) |
|
|
/B |
b |
/B/b |
/B/b |
|
|
/B |
c |
/A/b/c |
/B (no change) |
|
|
/A |
1 |
/A/b/1 |
/A (no change) |
|
|
/A/c |
a |
/A/a |
/A/c (no change) |
|
|
/B/3 |
b |
/A/b |
/B/3 (no change) |
|
|
(most places) |
(nothing) |
/B |
/B |
|
|
Suggestion: With your accounts in the following Domains or machine, add the following CDPATH definitions to the appropriate Resource files. With a careful choice of directories, you can switch to most of your folders without typing long pathnames. |
||||
|
Domain |
CDPATH definition (one line) |
Resource file |
||
|
Fulton |
set cdpath=( $HOME /d1/lnxi/$USER ) |
~/.cshrc |
||
|
Snug (Cobb) |
CDPATH=/gt/$USER:$HOME; export CDPATH |
~/.bash_profile |
||
|
DeKalb |
set cdpath=( /Volumes/SGIHarvey/$USER Documents ) |
~/.cshrc |
||
|
The definitions make use of variables ($HOME and $USER); you can substitute the proper values (type echo $HOME to see the value that is defined for this variable) or continue to use the variables. The definition for Snug (which is one machine in a future Cobb domain) is for a temporary file sharing scheme. The definition for the DeKalb domain makes sense only if you are in group 600 (harvey). If you are in group 700 (biology) use SGIBiology instead. This folder must be mounted or the definition will be ineffectual. You can set it as a login item. Perform this mount (see the Account Guide) before you do the following: launch System Preferences, select Login Items, click on the Add button and in the file browser that appears, go back to the root and look for SGIHarvey (or SGIBiology) and look for your folder, select it and click on the Add button. Now, whenever you login, this folder will be automounted. Note that /d1/lnxi/ is accessible only on Wart and Snug. |
||||
|
For the Fulton domain, we add the home directory (or whatever is defined in $HOME) to CDPATH. This is actually useful if you have many subfolders underneath the home directory. Even if you are in a deeply nested folder you can move to another subfolder underneath the home directory by giving a short pathname to that folder. The second definition is your home directory on Snug. The definition for Snug starts with your home directory in the Fulton domain followed by your home directory on Snug. Note that all the directories are on the same physical disks on Wart and the first directory in all three definitions correspond to exactly the same directory on Wart. The second folders in the Fulton and Snug definitions refer to the same directories on Wart. The Dekalb definition adds your home directory in the Fulton domain first. The second entry is the Documents folder in your home directory of your DeKalb account. For privacy and security, you should place all your documents in the Documents folder (in subfolders of course) and not directly in your home directory. |
||||
|
Alternatives: You can define symbols for directories and reference them. You can make symbolic links to deeply nested directories. CDPATH is unnecessary in a graphical environment. |
||||
|
|
|
|
|
|
|
|
|
|