Awesome Terminal upgrades - Part Two: Upgrade and use a newer version of ZSH on macOS

0xdonut

Mr F.

Posted on December 15, 2019

Awesome Terminal upgrades - Part Two: Upgrade and use a newer version of ZSH on macOS

This is part two in the "Awesome Terminal upgrades" series. In this short tutorial we will cover ZSH on macOS and how you can upgrade and manage it using Homebrew.

Install Homebrew

The missing package manager for macOS (or Linux)

We will be using Homebrew to manage everything for us, if you don't have it installed, go ahead and do it now!

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Enter fullscreen mode Exit fullscreen mode

By default OSX has ZSH installed, but we're going to use homebrew to install ZSH so we can upgrade it and keep up to date with new releases.

Confirm the current active zsh version:

zsh --version
Enter fullscreen mode Exit fullscreen mode

Confirm the location of zsh:

which zsh
Enter fullscreen mode Exit fullscreen mode

The output should look like /bin/zsh

Confirm the shell that’s set for your user:

dscl . -read /Users/$USER UserShell
Enter fullscreen mode Exit fullscreen mode

The output should look like UserShell: /bin/zsh

Install ZSH:

brew install zsh
Enter fullscreen mode Exit fullscreen mode

Use brew ZSH:

sudo dscl . -create /Users/$USER UserShell /usr/local/bin/zsh
Enter fullscreen mode Exit fullscreen mode

After that, restart your Terminal to have it take effect.

Now if you run which again, you’ll see the system is recognizing the one you installed:

which zsh
Enter fullscreen mode Exit fullscreen mode

The output should look like /usr/local/bin/zsh

Confirm you're running brew ZSH:

dscl . -read /Users/$USER UserShell
Enter fullscreen mode Exit fullscreen mode

The output should look like UserShell: /usr/local/bin/zsh

Change your shell to the right ZSH

sudo chsh -s $(which zsh)
Enter fullscreen mode Exit fullscreen mode

Sometimes Switching ZSH shells can throw up some unsuspected errors, so you might want to add this to your .zshrc

export PATH=$HOME/bin:/usr/local/bin:$PATH
Enter fullscreen mode Exit fullscreen mode

Awesome, your shell is now using ZSH managed by Homebrew!
You can update ZSH whenever you like, as well as your other Homebrew installs by running:

brew update && brew upgrade
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
0xdonut
Mr F.

Posted on December 15, 2019

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related