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.
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/
3den.zsh-theme adben.zsh-theme af-magic.zsh-theme afowler.zsh-theme agnoster.zsh-theme alanpeabody.zsh-theme amuse.zsh-theme apple.zsh-theme arrow.zsh-theme aussiegeek.zsh-theme avit.zsh-theme awesomepanda.zsh-theme bira.zsh-theme blinks.zsh-theme bureau.zsh-theme candy-kingdom.zsh-theme candy.zsh-theme clean.zsh-theme cloud.zsh-theme crcandy.zsh-theme crunch.zsh-theme cypher.zsh-theme dallas.zsh-theme darkblood.zsh-theme daveverwer.zsh-theme dieter.zsh-theme dogenpunk.zsh-theme dpoggi.zsh-theme dstufft.zsh-theme dst.zsh-theme duellj.zsh-theme eastwood.zsh-theme edvardm.zsh-theme emotty.zsh-theme essembeh.zsh-theme evan.zsh-theme fino-time.zsh-theme fino.zsh-theme fishy.zsh-theme flazz.zsh-theme fletcherm.zsh-theme fox.zsh-theme frisk.zsh-theme frontcube.zsh-theme funky.zsh-theme fwalch.zsh-theme gallifrey.zsh-theme gallois.zsh-theme garyblessington.zsh-theme gentoo.zsh-theme geoffgarside.zsh-theme gianu.zsh-theme gnzh.zsh-theme gozilla.zsh-theme half-life.zsh-theme humza.zsh-theme imajes.zsh-theme intheloop.zsh-theme itchy.zsh-theme jaischeema.zsh-theme jbergantine.zsh-theme jispwoso.zsh-theme jnrowe.zsh-theme jonathan.zsh-theme josh.zsh-theme jreese.zsh-theme jtriley.zsh-theme juanghurtado.zsh-theme junkfood.zsh-theme kafeitu.zsh-theme kardan.zsh-theme kennethreitz.zsh-theme kiwi.zsh-theme kolo.zsh-theme kphoen.zsh-theme lambda.zsh-theme linuxonly.zsh-theme lukerandall.zsh-theme macovsky-ruby.zsh-theme macovsky.zsh-theme maran.zsh-theme mgutz.zsh-theme mh.zsh-theme michelebologna.zsh-theme mikeh.zsh-theme miloshadzic.zsh-theme minimal.zsh-theme mira.zsh-theme mlh.zsh-theme mortalscumbag.zsh-theme mrtazz.zsh-theme murilasso.zsh-theme muse.zsh-theme nanotech.zsh-theme nebirhos.zsh-theme nicoulaj.zsh-theme norm.zsh-theme obraun.zsh-theme peepcode.zsh-theme philips.zsh-theme pmcgee.zsh-theme pygmalion-virtualenv.zsh-theme pygmalion.zsh-theme random.zsh-theme re5et.zsh-theme refined.zsh-theme rgm.zsh-theme risto.zsh-theme rixius.zsh-theme rkj-repos.zsh-theme rkj.zsh-theme robbyrussell.zsh-theme sammy.zsh-theme simonoff.zsh-theme simple.zsh-theme skaro.zsh-theme smt.zsh-theme Soliah.zsh-theme sonicradish.zsh-theme sorin.zsh-theme sporty_256.zsh-theme steeef.zsh-theme strug.zsh-theme sunaku.zsh-theme sunrise.zsh-theme superjarin.zsh-theme suvash.zsh-theme takashiyoshida.zsh-theme terminalparty.zsh-theme theunraveler.zsh-theme tjkirch_mod.zsh-theme tjkirch.zsh-theme tonotdo.zsh-theme trapd00r.zsh-theme wedisagree.zsh-theme wezm+.zsh-theme wezm.zsh-theme wuffers.zsh-theme xiong-chiamiov-plus.zsh-theme xiong-chiamiov.zsh-theme ys.zsh-theme zhann.zsh-theme
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 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
... # 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 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. 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/Ubuntu 22.04.