Converting macOS Terminal To zsh in Catalina

Published July 13th, 2020
4 minute read
Warning!
This was written over two years ago, so some information might be outdated. Frameworks and best practices change. The web moves fast! You may need to adjust a few things if you follow this article word for word.

In macOS Catalina the new default shell is now zsh. After upgrading, you might see the following message when you open up terminal:

1The default interactive shell is now zsh.
2To update your account to use zsh, please run chsh -s /bin/zsh.
3For more details, please visit https://support.apple.com/kb/HT208050.
1The default interactive shell is now zsh.
2To update your account to use zsh, please run chsh -s /bin/zsh.
3For more details, please visit https://support.apple.com/kb/HT208050.

Some of you may already use zsh! If so, congratulations, this article is worthless to you. However, if you're an old bash holdout like me, read on. This is how I upgraded my setup.

First, we'll run the command like the warning states:

1chsh -s /bin/zsh
1chsh -s /bin/zsh

Enter the sudo password and the command should change the shell. Nothing will be different until you open a new terminal window.

I like to use a status line plugin called Powerline to track things like the git branch and repository state in the terminal prompt. So first we'll install powerline with

1pip3 install powerline-status
1pip3 install powerline-status

Next copy the following into your ~/.zshrc file:

1# Powerline
2# https://github.com/powerline/powerline
3. /usr/local/lib/python3.7/site-packages/powerline/bindings/zsh/powerline.zsh
1# Powerline
2# https://github.com/powerline/powerline
3. /usr/local/lib/python3.7/site-packages/powerline/bindings/zsh/powerline.zsh

The defaults for powerline are usually fine for me, except I don't like the right column, so to disable that, go to the file at .config/powerline/themes/shell/default.json and clear out the "right" section:

1"right": []
1"right": []

Now we'll make sure we have git completion enabled in zsh, run brew install git zsh-completion and copy the following into your .zshrc file

1# Enable git autocomplete, first make sure homebrew is installed,
2# then run `brew install git zsh-completion`
3# make sure you do not miss the "git" part of the command!
4if type brew &>/dev/null; then
5 FPATH=$(brew --prefix)/share/zsh/site-functions:$FPATH
6 
7 autoload -Uz compinit
8 compinit
9fi
1# Enable git autocomplete, first make sure homebrew is installed,
2# then run `brew install git zsh-completion`
3# make sure you do not miss the "git" part of the command!
4if type brew &>/dev/null; then
5 FPATH=$(brew --prefix)/share/zsh/site-functions:$FPATH
6 
7 autoload -Uz compinit
8 compinit
9fi

Now you should be all set up! Note that if you want to see my exact config, my dotfiles are always available here

Enjoy this article? Follow me on Twitter for more tips, articles and links.
😢 Awww, nobody has liked or mentioned this on Twitter yet.

Want Updates?

Sign up here if you want to stay in the loop about new articles or products I'm making.
I'll never spam you. Unsubscribe at any time.
Copyright ©2024 Austen Cameron