14.5 Saving Time When You Change Directories: cdpathSome people make a shell alias ( 10.2 ) for directories they cd to often. Other people set shell variables ( 6.8 ) to hold the pathnames of directories they don't want to retype. But both of those methods make you remember directory abbreviations - and make you put new aliases or shell variables in .cshrc or .profile each time you want to add or change one. There's an easier way: the C shell's cdpath shell variable and the CDPATH variable in ksh , bash , and some versions of sh . I'll use the term "cdpath" to talk about all shells.
When you type the command
Let's say that your home directory is
/home/lisa
and your current
directory is somewhere else.
Let's also say that your
cdpath
has the directories
/home/lisa
,
/home/lisa/projects
, and
/books/troff
.
If your
%
Some Bourne shells don't show the directory name.
All shells print an error, though, if they can't find any So, set your cdpath to a list of the parent directories that contain directories you might want to cd to. Don't list the exact directories - list the parent directories ( 1.21 ) . This list goes in your .cshrc or .profile file. For example, lisa 's .cshrc could have:
A Bourne shell user would have this in .profile :
CDPATH=:$HOME:$HOME/projects:/books/troff export CDPATH
(If your system doesn't define
- |
|