Photo by Gabriel Heinzer / Unsplash

How to set up Zsh with Oh My Zsh and PowerLevel10K?

Linux Sep 8, 2023

Why use Zsh?

Zsh, or Z Shell, is an extended version of the Bourne Shell (sh), which is a widely used UNIX shell. There are several reasons why many users prefer to use Zsh:

  1. Enhanced User Experience: Zsh offers a more user-friendly and customizable experience compared to other shells. It comes with features like tab-completion, spelling correction, and advanced history management.
  2. Powerful Tab-Completion: Zsh's tab-completion is highly customizable and intelligent. It can complete commands, filenames, arguments, and even suggest completions based on the context.
  3. Plugins and Themes: Zsh has a vibrant ecosystem of plugins and themes. These can extend its functionality and improve your workflow. Popular plugin managers like Oh My Zsh and Zim make it easy to customize and enhance your shell environment. We will be using Oh My Zsh and PowerLevel10K to set up Zsh in this guide.
  4. Rich Configuration Options: Zsh has a wide range of configuration options, which allows users to tailor it to their specific needs. This includes customizable prompts, key bindings, and other settings.
  5. Extended Globbing: Zsh has powerful file globbing capabilities, allowing you to match files based on patterns, attributes, and more. This can be particularly useful for complex file operations.
  6. Support for pyenv and nvm: The best version management utilities for Python and Node are pyenv and nvm respectively. These can come in quite handy when working with projects that need different versions of Python or Node running. Zsh along with pyenv and nvm makes it a breeze to manage Python and Node versions.
  7. And much more...!

The Actual Setup

Step-1

The first step to set up Zsh on your system is to install Zsh. This step will not make Zsh your default terminal but you can take a peek at it by typing the zsh command in your existing shell after installing Zsh. To install Zsh, use the following commands.

sudo apt update
sudo apt install zsh
Running the command sudo apt update on a Linux terminal.
Running the command sudo apt install zsh on a Linux terminal.

Step-2

Next, you will have to install Oh My Zsh. 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...

You can visit their website for more information on their installation script or just execute it by copy-pasting the commands shown below.

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

Running the command to install Oh My Zsh i.e. sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Step-3

Once you have installed Zsh and Oh My Zsh, we will install a theme called PowerLevel10K. PowerLevel10k is a theme for Zsh. It emphasizes speed, flexibility and out-of-the-box experience.

We will first need to install a few fonts in order for this theme to work well. You can get them from here. Once you follow the link, get the four fonts named:

It is to be noted that MesloLGS NF Italic.ttf might not install on some Linux-based systems and that is fine. Just install the other three and you will be good to go.

Installing the fontMesloLGS NF onto the system.

Once the fonts have been installed, install the theme itself by running the following command.

git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
Running the command to install PowerLevel10K i.e. git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

Finally, set the theme to PowerLevel10K by editing the following line ZSH_THEME="powerlevel10k/powerlevel10k" in ~/.zshrc to load it by default.

Editing the line ZSH_THEME="powerlevel10k/powerlevel10k" in the ~/.zshrc file to change the default theme.

Step-4

Once you have set up Zsh, Oh My Zsh and PowerLevel10K you are all set! You just need to log out of your system and follow a few additional steps after logging back in before you can enjoy your Zsh setup.

After you open the terminal for the first time after you log back in, you will see the PowerLevel10K theme setup. Before starting with this wizard, make sure that you set the terminal application's font to MesloLGS NF otherwise you won't be able to complete the setup successfully.

Changing the font of the terminal application to MesloLGS NF.

Once you have added the fonts and followed through with the setup, you will have a functioning Zsh prompt as shown below.

A glimpse of a the Zsh prompt after running sudo apt update on it.

Next Steps

Now that you have come to the end of this guide and have successfully set up Zsh with Oh My Zsh and PowerLevel10K, there are a few more steps you can take to spice up your development experience by setting up Python and Node the right way on your system. To do so, you can follow along with the guides I will be releasing shortly for installing pyenv and nvm which are version management utilities for Python and Node.

Tags