In this tutorial, we are going to learn how to install and setup Zsh and Oh-my-Zsh on Ubuntu 20.04/Ubuntu 22.04.
Table of Contents
Install and Setup ZSH and Oh-My-Zsh on Ubuntu 20.04/Ubuntu 22.04
Z shell (ZSH) Zsh is a UNIX command interpreter (shell) usable as an interactive login shell and as a shell script command processor. It incorporates features of other shells such as Bash, tcsk, ksh. Some of the features include;
- Smart command TAB auto-completion
- Improved variable/array handling
- Spelling correction
- Enables sharing of command history among all running shells
- Editing of multi-line commands in a single buffer
- It is highly customization
Zsh configuration is managed by a delightful, open source and community-driven framework called Oh My Zsh. Oh My Zsh comes bundled with a ton of functions, helpers, plugins and themes that can be used to spice your shell experience.
In order to install and setup ZSH and Oh-My-Zsh on Ubuntu 20.04/Ubuntu 22.04, there are a few tools we will need. These include
git. They can be installed by running the command below;
sudo apt install wget curl git -y
Instal ZSH on Ubuntu 20.04/Ubuntu 22.04
ZSH is available on the default Ubuntu 20.04/Ubuntu 22.04 default repos. Thus to install it and its required dependencies, run the command;
sudo apt install zsh
To check installed version of ZSH;
zsh 5.8.1 (x86_64-ubuntu-linux-gnu)
Configure ZSH on Ubuntu 20.04/Ubuntu 22.04
You can begin by changing your default shell to zsh.
sudo usermod -s $(which zsh) kifarunix
If you are logged in on a shell you are on a standard user, simply change your shell by running;
chsh -s $(which zsh)
- If you do not have enough privileges to run
usermodcommand, simply check suggestions listed here or here on how to change shell as non-privileged user. Not sure it’s gonna work.
- Close the current terminal and open a new one to use your new shell.
- If this doesn’t work, simply logout and re-login. Once logged in, open a terminal. You will be prompted to set your Zsh start up files. See the screenshot below;
To populate your
~/.zshrc with the default configuration settings, select option 2.
You will immediately see changes on the appearance of your shell prompts.
To confirm the current shell;
Install Oh-my-Zsh on Ubuntu 20.04/Ubuntu 22.04
To be able to customize the appearance of your ZSH, you need the oh-my-zsh framework which can be installed by either using the
wget commands as shown below;
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
Upon installation, you will see yet another change in the appearance of your terminal.
Configure Oh-My-Zsh on Ubuntu 20.04/Ubuntu 22.04
Want the “oh-my-zsh” feeling, right? Proceed to configure it.
The Oh-my-Zsh configuration files are located under
$HOME/.oh-my-zsh/ directory. Note that ZSH config file is
Oh-My-Zsh Theme Configuration
Oh-My-Zsh themes are located under
ls -1 $HOME/.oh-my-zsh/themes/
To change the ZSH theme, open the configuration file,
$HOME/.zshrc, and set the value of
ZSH_THEME= to the name of your preferred theme.
robbyrussel is the default theme for ZSH.
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
To change the theme, simply get the name of the theme from
$HOME/.oh-my-zsh/themes/ and replace
robbyrussell with it.
For example, to change the theme to
$HOME/.oh-my-zsh/themes/gnzh.zsh-theme, update the ZSH_THEME line so it look like;
Save and exit the file.
~/.zshrc to effect the changes everytime you make changes.
This is how
gnzh theme looks like;
Want to use multiple selected themes randomly? Edit the
$HOME/.zshrc and set the theme to
Then, define the themes to use in a random manner as in;
ZSH_THEME_RANDOM_CANDIDATES=( "gnzh" "agnoster" "robbyrussel" )
Check more themes on ohmyzsh themes Github repository.
Oh-My-ZSH Custom Themes
There are also other external ohmyzsh themes that you can check on. Custom themes can be installed on
For example, let us try Powerlevel10k.
Install Powerlevel10k Oh-My-Zsh Theme
To install and use Powerlevel10k theme, you first need to install the recommended font,
Meslo Nerd Font patched for Powerlevel10k.
Meslo Nerd Font patched for Powerlevel10k fonts;
To instal the fonts, navigate to the downloads directory and double click and install each one of them so as to make
MesloLGS NF font available system wide.
Next, configure your terminal to use Powerlevel10k
MesloLGS NF font. Each type of terminal has a different way in which it can be configured to use this theme.
For example, to configure GNOME terminal to use this font;
- Right click anywhere on the terminal and select Preferences.
- On the selected profile, under
Text Appearanceand select
MesloLGS NF Regular.
- Once you set the theme, close the Preferences window.
Download and Install Powerlevel10k Oh-My-Zsh Theme
You can then download and install Powerlevel10k oh-my-zsh theme by running the command below;
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k
Once Powerlevel10k theme is in place, edit the Zsh configuration file,
$HOME/.zshrc, and change the theme to
Save and exit the Zsh configuration then reload the configs.
Upon reloading Zsh configs, Powerlevel10k configuration wizard will ask a few questions so as to configure your prompt.
Answer the questions appropriately.
Select your shell prompt.
Configure how you want your prompt to look like by going through a series of provided questions.
Once, done save the changes and your Powerlevel10k prompt now looks like;
oh my zsh!!! Isn’t it?
Enable Oh-My-Zsh Plugins on Ubuntu 20.04/Ubuntu 22.04
There are a ton of oh-my-zsh plugins to further spice up your shell. Plugins are stored under,
~/.oh-my-zsh/plugins. It is also possible to define custom plugin location, like,
Plugins can be enabled by defining them under the plugins section on
~/.zshrc config file. For example, to enable colored man pages plugin;
# Which plugins would you like to load?
# Standard plugins can be found in ~/.oh-my-zsh/plugins/*
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
Save and exit the shell. Then source
~/.zshrc for the changes to take effect.
The verify the plugin by running,
There are a lot of customizations that can be done on ZSH and Oh-My-Zsh. Feel free to explore. Otherwise, we have come to an end of our guide on how to install and setup ZSH and Oh-My-Zsh on Ubuntu 20.04/Ubuntu 22.04.