If you do any kind of development on Linux or a Mac you know how important and useful the terminal (Unix) shell is. If you are new to it all here’s a quick refresher on Terminals/Shells/Command Lines.
The standard and most popular Unix shell for years was the Bash shell. Over time the Z shell (zsh) which is an extended Bourne shell with enhanced features replaced the bash shell in popularity and in 2019 Mac OS Catalina made zsh the default login shell replacing bash.
If you are on an updated version of the Mac OS then, zsh should already be installed and your default login shell. You can check what is the default shell on your Mac by launching the Terminal app from the Launcher and in the terminal enter
echo $0 or echo $SHELL
If it says -zsh or /bin/zsh you can verify the version by entering the following in the terminal window
If you don’t have it installed or need to update the version, use the popular and our favorite package manager Homebrew to install it. If you don’t have brew installed follow the instructions here to install it first. Once you have brew installed, from the terminal app enter the following commands to first update brew and then install zsh
brew install zsh
If you are on the older Mac OS and zsh is not your default login shell you can enter the following command to make it your default shell
sudo sh -c "echo $(which zsh) >> /etc/shells" && chsh -s $(which zsh)
If you are on a Linux system, the process is similar. Most of the newer Linux distributions have zsh as the default shell but if you are on an older OS, you can check is zsh is installed and it’s version by entering zsh –version in your Linux terminal. If you need to install or update zsh, the commands are slightly different based on the flavor of your Linux OS and the package manager installed.
On Debian based systems (like Ubuntu) enter the following commands in the terminal shell
sudo apt update
sudo apt upgrade
sudo apt install zsh
On Redhat based systems (like Centos) enter the following commands in the terminal shell
sudo yum upgrade
sudo yum install zsh
On SuSe based systems enter the following commands in the terminal shell
sudo zypper upgrade
sudo zypper install zsh
To make zsh your default shell on Linux systems, after you have installed zsh enter the following in the terminal shell
sudo vi /etc/passwd
Find the line with your username:
and replace bash with zsh:
Log out and log in back for the changes to take effect.
Finally after your have zsh as your default shell, on Mac or Linux install the Oh My Zsh package. As their website so eloquently states…
Oh My Zsh is a delightful, open source, community-driven framework for managing your Zsh configuration. It comes bundled with thousands of helpful functions, helpers, plugins, themes, and a few things that make you shout…
“Oh My ZSH!”
You can browse their site Oh My Zsh – a delightful & open source framework for Zsh for instructions on installing the oh-my-zsh package or just enter the following in the terminal window
$ sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Once you’ve installed oh-my-zsh, you can browse the site for the large number of plugins and themes available to install. At a minimum we recommend you install the zsh-autosuggestions, zsh-completions and zsh-syntax-highlighting plugins.
If you get the following error in your zsh at some point…
compinit:503: no such file or directory ....
Run the following command from the shell
Oh My Zsh will regularly alert you on updates available but if you ignore those updates and need to update manually just type in the following command from your omz terminal