The Ultimate Terminal Emulator with Oh-My-Zsh Experience

Vincent Liu
The Startup
Published in
6 min readApr 17, 2020
fortune -s computers | cowsay -f dragon | lolcat

The terminal may be old school, but it doesn’t have to be boring. Let’s make it interesting. 🤓

Install & Configure iTerm2 ⚙️

If you’re on a macOS, I strongly suggest you switch from the default Terminal app to iTerm2 because it is way more customizable. However, if you prefer to use the default Terminal or you’re on a different OS (e.g. Ubuntu), you can skip this step and use whichever terminal app you prefer.

The following is the single command required to install iTerm2 on macOS using Homebrew🍺:

brew cask install iterm2
Blank slate iTerm2

Now that we have a clean slate iTerm2, let’s start by downloading the material design color theme. There are a ton of themes available at iTerm Themes. I personally prefer this specific Material Design Theme by Martin Seeler:

Material design color palette by Martin Seeler

To enable it:

  1. Go to iTerm2 > Preferences > Profiles > Colors Tab
  2. Click on Color Presets… > Import…
  3. Select the theme-of-your-choice file
  4. After import, select the theme-of-your-choice-colors from Color Presets…

Additional Customizations

The status bar configuration screen
iTerm2 status bar components w/ Auto-Rainbow on

iTerm2 offers a very handy Status Bar view that you can customize to display the components of your desires.

To enable it:

  1. Go to iTerm2 > Preferences > Profiles > Session
  2. Turn on Status bar enabled
  3. Click on Configure Status Bar to begin setting up your status bar configuration by dragging components from Status Bar Components Menu into Active Components.
  4. Click on Auto-Rainbow to finalize with a colorful touch 🌈

Additional Settings (Personal Preferences) ⚙️

Window settings
Text settings

Install ZSH

Why ZSH? It offers many features over the default Bash. Here are some of the major improvements:

  • Automatic cd: Change directory without typing ‘cd’
  • Recursive path expansion: For example, “/u/lo/b” expands to “/usr/local/bin”
  • Spelling correction and approximate completion: ZSH automatically fixes any minor mistakes you make when typing a directory name
  • Plugin and theme support: ZSH has many different plugin frameworks and themes available
Ubuntu 🐧: sudo apt install zsh
macOS 🍎: brew install zsh

Install Oh-My-Zsh 🙀

Oh-My-Zsh is the most popular framework for managing ZSH configuration and it comes with a ton of plugins to take advantage of. Check out its Github Wiki for a complete list of the plugins available.

via curl

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

via wget

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

Enable Plugins

To enable the plugins, you need to add them to the .zshrc file located in your $HOME directory. Open it with your favorite editor and place them under the plugins section.

# An example of a plugin settingplugins=(
git
osx
zsh-autosuggestions
docker
zsh-syntax-highlighting
iterm2
)

Themes 🎨

There are over one hundred themes bundled with Oh-My-Zsh that you can choose from. Check out these screenshots on their wiki to find the perfect one for you. To enable the theme of your preference, open .zshrc file and find an environment variable:

ZSH_THEME="robbyrussell"

Change the value to your favorite theme and you’re good to go. You may also change it to random to use a random theme every time you start up a new terminal window.

Tip: A lot of the themes bundled with Oh-My-Zsh require the Powerline Fonts in order to render properly.

Open up a new terminal window and it should look something like this:

ZSH_THEME=”agnoster”

Custom Themes 🎨

The powerlevel9k theme is probably by far the coolest theme of all. It allows the configurations to add additional infoboxes to the left and right of the terminal. To get the most out of powerlevel9k theme, you need to use a terminal with 24-bit color. To set up this theme (or any other custom themes that are not bundled with Oh-My-Zsh), just clone the repository into the .oh-my-zsh custom themes folder:

git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k# To enable powerlevel9k, simply change the value to: ZSH_THEME="powerlevel9k/powerlevel9k"

If you’re on macOS, you can install it with Homebrew🍺:

brew tap sambadevi/powerlevel9k
brew install powerlevel9k
# To load powerlevel9k in your zsh simply add the following line to your .zshrc:
source /usr/local/opt/powerlevel9k/powerlevel9k.zsh-theme

# Alternatively you can run this command to append the line to your .zshrc:
echo "source /usr/local/opt/powerlevel9k/powerlevel9k.zsh-theme" >> ~/.zshrc

Nerd Fonts ✍🏻

I also prefer to use Hack Nerd Font to go along with the theme. Nerd Fonts are a collection of patched developer targeted fonts with a high number of glyphs.

macOS and Linux via Install Script:

# A shallow clone is sufficient
git clone --depth 1 git@github.com:ryanoasis/nerd-fonts.git
# Install all the patched Fonts
./install.sh
# Install a single Font of your choice (Recommended way because installing all the patched fonts can add up to a large size
./install.sh <FontName>
./install.sh Hack
./install.sh HeavyData

macOS with Homebrew🍺:

brew tap homebrew/cask-fonts
brew cask install font-hack-nerd-font

Update iTerm2:

  1. Go to iTerm2 > Preferences > Profiles > Text
  2. Click on Font and select Hack Nerd Font
  3. Click on Non-ASCII Font and select Hack Nerd Font
  4. Make sure Use Ligatures is turned on for better experience

At this point, your terminal window should look something like this:

If the icons are not showing, add this line to the .zshrc: POWERLEVEL9K_MODE=’nerdfont-complete’

Powerlevel9k Configuration ⚙️

Customization is the name of the game. Here are my configs:

Check out their full documentation on more configuration options and check out Show Off Your Config to see what other people have done or show off yours! 🤓

Final results with the configuration

Final Touch 💅

Some people like to use neofetch which is a command-line system information tool that displays information about your OS, software, and hardware.

Install neofetch:

Ubuntu 🐧: 
sudo apt update
sudo apt install neofetch
macOS 🍎:
brew install neofetch
Neofetch will by default create a config file at $HOME/.config/neofetch/config.conf on the first run

Tip: You can further customize the system information displayed. Visit this wiki for more information.

To display this every time you open a new terminal window, open up .zshrc or .zlogin and add this line so it runs neofetch at startup:

neofetch

Install fortune 🥠 & cowsay 🐮 & lolcat 😹 :

Instead of neofetch, I prefer to install this combination of CLI tools to have a little fun when the terminal starts up.

Ubuntu 🐧: 
sudo apt-get update
sudo apt-get install fortune
sudo apt-get install cowsay
gem install lolcat
macOS 🍎:
brew install fortune
brew install cowsay
brew install lolcat

Open up the .zlogin file found in the $HOME directory and add this line:

fortune -s computers | cowsay -f dragon | lolcat
Final product 😎

Or if you’re a Pokémon fan… 🤔

Install pokemonsay (requires cowsay to work):

git clone http://github.com/possatti/pokemonsay
cd pokemonsay
./install.sh

macOS with Homebrew 🍺:

brew tap possatti/possatti
brew install pokemonsay
pokemonsay -p Pikachu “Gotta catch’em all”

You can catch more Pokémon in their official documentation! 🙊

Other Useful CLI Tools & Aliases 🔨

  • TheFuck — A magnificent tool that corrects errors in your previous console commands in an elegant way 😉
Ubuntu 🐧: sudo pip3 install thefuck
macOS 🍎: brew install thefuck
# After installation, add these two lines to your .zshrc file
eval "$(thefuck --alias)"
alias fuck='fuck -y'
Simply beautiful :’)

Thanks for reading! 😸

--

--

Vincent Liu
The Startup

The worst code I’ve seen is the code I wrote six months ago. 🙊🙈🙉