Whether you want to switch your terminal shell because you’re curious about what lies beyond Bash or if you’re doing so because Apple is advising Mac users to switch to the zsh shell, there is really nothing to lose by trying something new. This article will go over how to get started using the zsh shell, taking advantage of the oh my zsh framework, how to setup themes, and other helpful plugins.

I first found out about zsh while using a linux machine running Elementary OS. At the time, it was simply out of curiosity. Today, using zsh has proven much more efficient than the bash shell that usually comes preinstalled on most unix and linux systems. It offers more productivity capabilities, theming, and a friendlier MIT license than the GPL v3(at the time of writing) which Bash is using.

Getting Started

If you’re not sure what shell you’re using, then run echo $0 in your terminal to view your default shell. If zsh is the default shell, then you can skip to the oh my zsh section. If bash is the default shell, ensure that zsh is installed on your system by running which zsh. If you don’t get any output, then proceed to install zsh via your package manager. On mac, run brew install zsh. On Ubuntu-based systems with the APT package manager, run sudo apt install zsh.

To switch to the zsh shell, there is a simple command you can run in your terminal to do so.

chsh -s /bin/zsh

Is the zsh shell really that different?

From a usage point of view, zsh is really not so different from bash. The real difference is in the configuration options and customizability which are what really attract a lot of users to make the switch in the first place.

Giving zsh more power with Oh My ZSH

A delightful community-driven (with 1500+ contributors) framework for managing your zsh configuration. Includes 200+ optional plugins (rails, git, OSX, hub, capistrano, brew, ant, php, python, etc), over 140 themes to spice up your morning, and an auto-update tool so that makes it easy to keep up with the latest updates from the community. - Oh My Zsh Github Page

To install the Oh My Zsh framework in order to take advantage of its customizability options:

  • Ensure you have curl or wget installed
  • Run:
# if using curl
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

# if using wget
sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Once the installation is complete, you now have the ability to add themes and plugins to your zsh configuration file.

Adding a theme

There are hundreds, if not thousands of themes you can pick for your zsh shell. If you’re anything like me, then a minimal theme will do the trick. I’m currently using the default robbyrussell theme which comes bundled with Oh My Zsh. But if you want to setup a different theme, then find the ZSH_THEME variable in your ~/.zshrc configuration file and assign it the theme of your choice.


Useful Plugins

For me, beyond the aesthetics, I love zsh for the plugins it allow me to use. One of my favorite is the zsh-autosuggestions plugin which saves me a lot of typing time by auto-suggesting and auto-completing commands if they’re in the shell’s history.

Here’s how you would install the zsh-autosuggestions plugin and add it to the zsh configuration file. First, you’ll need to install it via your distribution’s package manager or clone it from their github repo. I prefer the latter.

git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

If you’d like to explore other installation options, visit the plugin’s github repo

The next step is to add the plugin to your zsh configuration file. Open your ~/.zshrc file and add the plugin to the plugins variable. If you already have other plugins, separate the plugins with a space.

# Inside you ~/.zshrc file
# This shows a scenario where you have another plugin installed
plugins=(git zsh-autosuggestions)

Save your file and start a new terminal session to see your changes.

The Zsh shell is truly a powerful tool. I’ve only explored the basics and I hope you’ll have fun looking more into it and customizing it to your tastes.