Configuring Zsh

Configuring Zsh


This is a quick and easy guide for installing zsh, setting up a basic configuration, and enabling it as your default shell. I've used bash with bash-completion for as long as I can remember, and recently switched over to zsh for day-to-day usage. Lots of plugins, options, and customization. These instructions should work on just about anything running zsh.


Installing Zsh

The first step is simple: install zsh if you don't have it. Zsh is the default shell on macOS Catalina. You'll also need git installed.

# Ubuntu
sudo apt-get update
sudo apt-get install git
sudo apt-get install zsh

# Arch Linux
sudo pacman -S git zsh

# macOS Catalina
# Just open Terminal, you already have zsh :).

Easy enough. We'll now get a few items configured before we set it as our default shell. Depending on your terminal emulator, I'd highly recommend the MesloLGS NF font. It looks great and displays all the bells and whistles as expected.

Installing Oh-My-Zsh

Oh-My-Zsh is a must-have for zsh. It adds a ton of functionality and plugins. The installation is dead-simple too. Keep in mind we're still in bash since we've installed zsh but haven't switched shells yet.

sh -c "$(curl -fsSL"

It'll ask you if you'd like to switch shells, which you can say Y to at this point. You'll see output similar to this:

nlabadie@nathanlabadie:~$ sh -c "$(curl -fsSL"
Cloning Oh My Zsh...
Cloning into '/home/nlabadie/.oh-my-zsh'...
remote: Enumerating objects: 1158, done.
remote: Counting objects: 100% (1158/1158), done.
remote: Compressing objects: 100% (1127/1127), done.
remote: Total 1158 (delta 20), reused 1059 (delta 15), pack-reused 0
Receiving objects: 100% (1158/1158), 778.12 KiB | 15.56 MiB/s, done.
Resolving deltas: 100% (20/20), done.

Looking for an existing zsh config...
Using the Oh My Zsh template file and adding it to ~/.zshrc.

Time to change your default shell to zsh:
Do you want to change your default shell to zsh? [Y/n] Y
Changing the shell...
Shell successfully changed to '/usr/bin/zsh'.

         __                                     __
  ____  / /_     ____ ___  __  __   ____  _____/ /_
 / __ \/ __ \   / __ `__ \/ / / /  /_  / / ___/ __ \
/ /_/ / / / /  / / / / / / /_/ /    / /_(__  ) / / /
\____/_/ /_/  /_/ /_/ /_/\__, /    /___/____/_/ /_/
                        /____/              now installed!

Before you scream Oh My Zsh! please look over the ~/.zshrc file to select plugins, themes, and options.

• Follow us on Twitter:
• Join our Discord server:
• Get stickers, shirts, coffee mugs and other swag:

➜  ~

Congrats, you're now running zsh. Next we'll install a few more plugins that add auto-completion and syntax highlighting features.

git clone ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

One more that adds fuzzy searching:

git clone --depth 1 ~/.fzf

# Answer yes to everything followed by this command:
source .zshrc

Installing Powerlevel10K

First you'll want to install the MesloLGS NF font. This is particular to Arch Linux:

yay -S ttf-meslo-nerd-font-powerlevel10k

Next we're going to install the Powerlevel10K theme. The install is simple:

git clone --depth=1 ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

We're not going to enable it just yet though. First, we'll back up the .zshrc file and then add a few lines to it.

cd ~
cp .zshrc .zshrc-`date "+%Y%m%d"`
vi .zshrc

# Comment out the following line and add this.

# Also comment out this line and add the following.

Configuring Powerlevel10k

At this point we need to source the .zshrc file. It'll also kick us into the Powerlevel10k setup screen. Remember that font I'd mentioned before? Powerlevel10K uses it, e.g. showing a lock when you're in a directory where you don't have write permissions.

source .zshrc

It'll ask you a bunch of questions. You're free to choose whatever you'd like during setup, but I'm a fan of simplicity. Pay attention to the font questions at the beginning. However, it shouldn't be an issue if you're using the MesloLGS NF font since it'll display the icons correctly.

Here's the quick answers that I use:

y, y, y, y, 1, 1, 1, 1, 1, 1, 1, 1, y, 1, y


At this point you should have a fancy-yet-simple terminal using zsh:

Hope this helps!

Show Comments