Why zsh?

zsh csh on the sea shore.

For the last month or so I've been experimenting with different shells, from bash to fish to xonsh. I eventually settled on zsh, and I am very satisfied with it so far. There are a few reasons why I picked zsh.

One, zsh is almost completely compatible with bash. This makes switching from one to the other quite painless.

Two, I've found zsh to be faster than bash. When I open a new terminal window, the zsh prompt appears significantly faster than my bash prompt used to.

Three, there is oh-my-zsh for plugins. This makes getting and loading custom pieces of shell script much easier.

Four, autocompletion is built right into zsh, unlike bash. This makes it faster.

Five, if one uses vi-style key bindings, one can customize the prompt based on the mode. In bash, all that can be done is to use the readline feature of displaying a different character at the start of the prompt based on mode. This is not a particularly nice solution. Zsh provides a hook to do anything when the mode changes:

function zle-line-init zle-keymap-select {
  case $KEYMAP in
    vicmd)
      # ...
      ;;
    viins|main)
      # ...
      ;;
  esac
  zle reset-prompt
}

zle -N zle-line-init
zle -N zle-keymap-select

Now that I'm using zsh, my series of Bash Tricks I Like will probably change to Zsh Tricks I Like, or perhaps a more generic Shell Tricks I Like. We shall see.