p:: CLI f:: bash, Oh My Zsh

The Z shell — a bash-compatible interactive shell with better completion, globbing, and prompt theming. Oh My Zsh is the config framework most people actually install it for, and it needs zsh 5.0.8 or newer.

Install

SystemCommand
Arch / Manjaro / Omarchysudo pacman -S zsh
Ubuntu / Debian / WSLsudo apt install zsh
macOSbrew install zsh
Fedorasudo dnf install zsh
Alpineapk add zsh
Termux (Android)pkg install zsh

macOS has shipped zsh as the default shell since Catalina — check zsh --version before reaching for Homebrew.

Verify

zsh --version
zsh 5.9.2 (aarch64-unknown-linux-gnu)

Default Shell

chsh -s $(which zsh)

Log out and back in, then confirm from a fresh terminal:

echo $SHELL
/usr/bin/zsh

Gotchas

  • chsh only accepts a shell listed in /etc/shells. If it refuses, append it first: sudo sh -c "echo $(which zsh) >> /etc/shells".
  • Fedora wants sudo chsh $USER instead (older versions: sudo lchsh $USER).
  • Intel Macs need the full path — chsh -s /usr/local/bin/zsh — since Homebrew’s zsh is not on the system path at login.
  • Where chsh is unavailable (locked-down or LDAP accounts), put exec zsh at the top of ~/.bashrc instead.

Corrupt history file

How to fix a corrupt zsh history file

{
  cd ~
  mv .zsh_history .zsh_history_bad
  strings .zsh_history_bad > .zsh_history
  fc -R .zsh_history
}