Setting up ZSH on a Mac

I’ve been using the excellent Fish shell for the last few (three? four?) years, but every once in a while I need bash-compatibility, and Zsh seemed like perhaps a sweet spot between the two.

If you’re in a similar spot, this is a two-minute (almost) guide to getting up and running with Zsh on OS X.

Step 1: What does brew have?

~> brew search zsh
==> Searching local taps...
zsh ✔                                zsh-autosuggestions                  zsh-git-prompt                       zsh-lovers                           zsh-syntax-highlighting
fizsh                                zsh-completions                      zsh-history-substring-search         zsh-navigation-tools                 zshdb

Step 2: Just install the main product

So brew has a lot of packages, but I just need zsh for now.

Step 3: Use it!

I used to have this two step process of first adding it to /etc/shells and then calling chsh -s on it, but there’s a better way to do it:

sudo dscl . -create /Users/$USER UserShell /usr/local/bin/zsh

Step 4: Configuration options

Here you can either create .zshrc files manual, or through the startup menu, or … use Oh-my-zsh/Prezto.

I went with the last one, but here’s what the “first time menu” looks like:

Please pick one of the following options:

(1)  Configure settings for history, i.e. command lines remembered
 and saved by the shell.  (Recommended.)

(2)  Configure the new completion system.  (Recommended.)

(3)  Configure how keys behave when editing command lines.  (Recommended.)

(4)  Pick some of the more common shell options.  These are simple "on"
 or "off" switches controlling the shell's features.

(0)  Exit, creating a blank ~/.zshrc file.

(a)  Abort all settings and start from scratch.  Note this will overwrite
 any settings from zsh-newuser-install already in the startup file.
 It will not alter any of your other settings, however.

(q)  Quit and do nothing else.  The function will be run again next time.
--- Type one of the keys in parentheses ---

Step 5: Prezto

Pretty straightforward to install, and you can keep tweaking later, if that’s what you want.

git clone –recursive “$ZDOTDIR:-$HOME/.zprezto”

And then

for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^; do
  ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}"

That’s it, open a new terminal and enjoy your new shell!