Command Prompt
Change Directory
    Auto cd
    Named Directories
    Directory Stack
Command History
Key Bindings
Startup and Termination
Update List of Commands


zsh options are case insensitive and underscores are ignored. An option name may be inverted by preceding it with ‘no’, so setopt No_Beep is equivalent to unsetopt beep. [Manual]

Command Prompt

autoload -Uz promptinit
-U: suppress alias expansion when the function is loaded
-z: mark the function to be autoloaded using the zsh style
$ prompt adam1
select adam1 prompt scheme
$ prompt -l
list available prompt themes
$ whence -f promptinit
display promptinit function


To load completion:

autoload -Uz compinit

zstyle ':completion:*' menu select=3
menu selection will only be started if there are at least 3 matches
zstyle ':completion:*:correct:*' insert-unambiguous true
the completer will start menu completion only if it could find no unambiguous initial string at least as long as the original string typed by the user

Change Directory

Auto cd

setopt auto_cd
if command can’t be executed and the command is the name of a directory, perform cd to that directory

Named Directories

Frequently used directories can be abbreviated.

hash -d ff=$HOME/soft/firefox/
determine name ff for directory $HOME/soft/firefox/
To change into the directory: $ cd ~ff
$ hash -Ld
show the list of named directories

Directory Stack

setopt auto_pushd
cd dir-name results in adding dir-name onto the directory stack
setopt pushd_ignore_dups
don’t push multiple copies of the same directory onto the directory stack
dirs -v
show numbered list of directories in the stack
pushd dir-name
add dir-name to the stack
popd +2
remove the stack entry #2 from top in numbered representation


Frequently used commands can be abbreviated.

alias ll='ls -al --color --group-directories-first'
determine command ll
$ alias
show the list of aliases

Command History

setopt share_history
zsh’s running in different windows share the same history
setopt hist_ignore_all_dups
if a new command duplicates an older one, the older command is removed
setopt hist_ignore_space
command starting with a space is not added to the history
setopt hist_reduce_blanks
removing any excess blanks that mean nothing to the shell
maximum number of history events kept within one session
maximum number of history events to save in the history file
file to save history. If unset, the history is not saved

Key Bindings

bindkey command manipulates keymaps and key bindings.

bindkey "^[[1;5D" backward-word
Ctrl+←: move to the beginning of the previous word
bindkey "^[[1;5C" forward-word
Ctrl+→: move to the beginning of the next word

read shows what key is typed.

Startup and Termination

User's Guide: All the startup files

Order of initialization files:




Update List of Commands

zsh does not automatically recognize new commands after installation of new packages.

$ rehash
refresh cache of executable commands


Debian Wiki