LANGUAGE » SHELL_SCRIPT » ZSH

Built-ins

Man page

shell
man zshbuiltins

Change directory

The tool cd can be used to change directory. When using +n, it uses the directory stack.

shell
cd OPTIONS DIR
cd OPTIONS OLD NEW
cd OPTIONS {+|-}n
OptionDescription
-qDo not print the new directory stack.
-sDo not change directory if DIR contains symlinks.
-PResolve symlinks into their true values.
-LDo not resolve symlinks into their true values.

Examples

shell
cd destination/path
cd -   # Last path (cd specific)
cd ~-  # Last path (expanded by the shell)
cd ~2  # From directory stack id 2 (expanded by the shell)

Directory stack

It is possible to navigate between multiple directories efficiently. For this we use a directory stack, that can be accessed by pushd popd dirs.

Pushd

Push a directory into the stack, and cd into it.

shell
pushd OPTIONS DIR
pushd OPTIONS OLD NEW
pushd OPTIONS {+|-}n
OptionDescription
-qDo not print the new directory stack.
-sDo not change directory if DIR contains symlinks.
-PResolve symlinks into their true values.
-LDo not resolve symlinks into their true values.

Popd

Pop a directory from the stack, and cd into it.

shell
popd OPTIONS
popd OPTIONS {+|-}n
OptionDescription
-qDo not print the new directory stack.

Dirs

Print the directories in the stack.

shell
dirs OPTIONS
OptionDescription
-cClear the directory stack.
-lPrint directory names expanding ~.
-pPrint one entry per line.
-vEnumerate the directories in the stack.