Skip to main content

โš™๏ธ Configuration and Options

Set and unset optionsโ€‹

Zsh option names are case-insensitive, and underscores are ignored. For example, allexport and ALL_EXPORT refer to the same option. Prefix a name with no to invert it, so setopt no_beep is equivalent to unsetopt beep.

See the Zsh Options manual for the complete option reference.

History configurationโ€‹

The following is a practical starting point for interactive history:

~/.zshrc
setopt append_history # Append history instead of replacing the history file.
setopt extended_history # Save timestamps and command durations.
setopt hist_expire_dups_first # Expire duplicates first when trimming history.
setopt hist_find_no_dups # Do not display an entry already found in a search.
setopt hist_ignore_all_dups # Remove older duplicates when adding an entry.
setopt hist_ignore_dups # Do not record an entry identical to the previous one.
setopt hist_ignore_space # Do not record commands that start with a space.
setopt hist_reduce_blanks # Remove extra blanks from stored commands.
setopt hist_save_no_dups # Do not write duplicate entries to the history file.
setopt hist_verify # Load history expansions into the editor before running them.

# Choose one immediate-write mode:
setopt inc_append_history # Write each command immediately for independent sessions.
# setopt share_history # Import and append commands across active sessions.
Choose one history-sharing mode

Do not enable INC_APPEND_HISTORY and SHARE_HISTORY together. SHARE_HISTORY already appends commands incrementally and adds extended timestamps while importing commands from other sessions.

Other interactive optionsโ€‹

Review each option before enabling it, because options change shell-wide behavior.

~/.zshrc
setopt auto_cd # Change directory by entering a directory name.
setopt auto_list # List choices after an ambiguous completion.
setopt auto_pushd # Push the previous directory onto the directory stack.
setopt bang_hist # Enable csh-style history expansion with !.
setopt interactive_comments # Allow comments in interactive shells.
setopt multios # Use implicit tees or cats for multiple redirections.
setopt no_beep # Do not beep on errors.
setopt prompt_subst # Expand parameters and substitutions when drawing the prompt.
setopt pushd_ignore_dups # Avoid duplicate entries in the directory stack.
setopt pushd_minus # Exchange the meanings of + and - in stack indices.