Last Updated:

Spice up your CLI! Part 1: iTerm2 & ZSH 

This is a renewed attempt on a series that I tried to start a while ago. I'm a huge fan of the CLI, stemming from my DOS days in the 90's and throughout my career using Linux over the past 15 years - if you do software development, DevOps, AI/ML, etc, chances are you have already been using the CLI.

I often see people using the plain default shell, with the basic built-in terminal, but there is much more efficiency that can be unlocked, with little effort.

In this series I'll be aiming to share some of these tips and tricks to hopefully increase your productivity on the CLI. I'll be focusing mainly on MacOS, as this is my preferred operating system to work on. You can find installation instructions for pretty much any Linux distribution for ZSH, and for the Windows Subsystem for Linux (WSL).

In part 1, we'll be installing iTerm2, and changing our shell from the default BASH, to ZSH. 

In this series, we'll assume that you are already have some proficiency on the CLI. If not, there are many fanastic guides online to help you with basic commands and syntax - here is an example.

What is iTerm?

iTerm2 is a feature-rich drop-in replacement for the default Terminal application on MacOS. It has an extensive list of features and visually much nicer defaults. I usually recommend this to everyone to set as their default terminal. Head on over to the iTerm2 website to download and install it. To start off with, the only thing I would suggest changing is the scrollback lines to unlimited (Preferences → Profiles → Default → Terminal → Unlimited scrollback).

Side-note: if you're a Windows user, I recommend the Windows Terminal.

What is ZSH?

ZSH is a powerful shell - you can think of ZSH as an extended version of BASH (Born Again Shell), with improvements and additional features, such as:

  • Drop-in replacement for BASH
  • Command-line completion
  • Shared history
  • Spelling correction
  • Theme-able
  • Fully customisable
  • Extended modules: TCP system, FTP, calendar functions and many more!

Installing ZSH on MacOS

When I originally wrote this (8 years ago!), ZSH wasn't adopted as much as it is today; chances are, if you are using a modern version of MacOS, your default shell may already be ZSH (Apple changed from an older version of BASH (3.2) to ZSH by default a few years ago). To check this run the following command:

echo $SHELL

You should expect to see /bin/zsh if you're already using ZSH. If not, you can change your default shell to ZSH:

chsh -s /bin/zsh

You should be all set! I wouldn't worry about these too much yet, but you can have a look at some of the modules that ZSH can provide:

man zshmodules

Important note when using ZSH - when you install new executables/binaries to your $PATH, you will need to force ZSH to rebuild the $PATH hash. To do this, run the rehashcommand.

⏭ Click here for Part 2, where we'll be installing oh-my-zsh for theme and plugin support!