cdis used to change your current working directory. It can be used in a variety of useful ways. (You may also use
chdirinstead; they are the exact same.)
cdis as follows:
||Place you in your home directory, |
||Place you in the directory called
||Place you in the directory you were just in,
zsh adds some useful functionality to
First, if zsh doesn't find
NEW_DIR in the current
NEW_DIR isn't an absolute path), zsh looks
at the shell variable
cdpath. It looks for a subdirectory
NEW_DIR in each directory of
cdpath. If zsh
NEW_DIR, it goes there.
Furthermore, if you like, you can store the FULL pathname of a
directory in a shell variable. You can then type
and go into the directory contained in the shell variable VAR.
lyric > XDIR=/usr/lib/X11 lyric > cd XDIR ~XDIR lyric > pwd /usr/lib/X11 lyric >
Why is this useful? Why not just type
cd $XDIR each time?
The reason is that you get the added benefit of zsh making
XDIR a named directory. Essentially,
this means that the directory can get special treatment in prompt
expansion, and various builtins.
cd OLD NEW
and zsh replaced any occurance of
the current directory with
NEW, and then
cd's into it.
A simple example:
lyric > pwd /usr/local/encap/fvwm-2.2/libexec/fvwm/2.2 lyric > cd 2.2 2.0.46 /usr/local/encap/fvwm-2.0.46/libexec/fvwm/2.0.46 lyric >
To see the directory stack, type
Giving an arg of '+n' will extract the nth item from the directory stack, counting from the left (top). Using a '-' counts from the right (bottom).
If you would like to switch the meanings of '+' and '-', turn on the
cdbuiltin can take a few arguments:
||Don't cd into
||Resolve all symlinks to their true values before changing to
||Symlinks are followed, ignoring the |
Note: Turning on the shell option
CHASE_LINKS is the same
-P argument to