In this tutorial, we are going to learn how to install and setup Zsh and Oh-my-Zsh on Ubuntu 20.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.
Want to install Ubuntu 20.04 on VirtualBox? Follow the link below to setup one.
Install and Setup ZSH and Oh-My-Zsh on Ubuntu 20.04
In order to install and setup ZSH and Oh-My-Zsh on Ubuntu 20.04, there are a few tools we will need. These include
git. They can be installed by running the command below;
apt install wget curl git -y
Instal ZSH on Ubuntu 20.04
ZSH is available on the default Ubuntu 20.04 default repos. Thus to install it and its required dependencies, run the command;
apt install zsh
To check installed version of ZSH;
zsh 5.8 (x86_64-ubuntu-linux-gnu)
Configure ZSH on Ubuntu 20.04
You can begin by changing your default shell to zsh.
usermod -s $(which zsh) koromicha
If you are logged in on a shell you are on a standard user, simply change your shell by running;
chsh -s $(which zsh)
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;
[email protected] ~ % echo $SHELL /usr/bin/zsh
Install Oh-my-Zsh on Ubuntu 20.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
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
$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 ZSH_THEME="robbyrussell" ...
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 themes to
~/.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
... # ZSH_THEME="robbyrussell" # ZSH_THEME="gnzh" ZSH_THEME="powerlevel10k/powerlevel10k"
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 promt.
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
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. plugins=(git colored-man-pages)
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.