How To Install Oh My Zsh on Ubuntu

When you’re using Linux, the majority of the user time you spend in a terminal. An attractive terminal allows us to improve personal productivity and enjoy the process of work. If you’d like to customize your terminal and make it look professional, we’ll show you how you can use Oh My Zsh to achieve this goal. In this article, we’ll describe how to install and configure a beautiful terminal for your Ubuntu Linux.

Oh My Zsh

Oh my Zsh is a community-driven open-source framework that you can use for managing the Zsh configuration. Take a look at Which terminal is better: Bash vs Zsh to learn more about Zsh.

Zsh has a lot more useful functions, themes, helpers, plugins, and other features that will help you get more out of your shell.

Currently Oh My Zsh is capable of supporting 150 themes and 275 plugins.

Now, let’s head towards the process of customizing Oh My Zsh on Ubuntu.

Oh My Zsh installation

In this section we’ll cover the Oh My Zsh installation process.

Before making any changes in my system I’d prefer to test them first. The ideal option is to use Ubuntu Docker image. The primary reason here is an ability to reset the container if something goes wrong.

To launch Docker container use the following commands:

docker run -it ubuntu:20.04 /bin/bash

Default Ubuntu Docker image does not contain Zsh, you, you have to install it first:

apt-get update
apt-get install -y zsh

Now, you can launch Zsh terminal:

zsh --version
zsh
2. Which terminal is better - Bash VS Zsh - Launch zsh

Starting from now, all commands will be the same for Ubuntu Docker container and your Ubuntu system.

First, we need to make sure, that we have required packages on our system which include git, curl, and wget:

apt-get update && apt install -y curl wget git

Next, install the latest version of Oh My Zsh framework:

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
14. Which terminal is better - Bash VS Zsh - Bash typo example - Zsh - Oh My Zsh setup

Answer Y to switch your default shell to Zsh.

Setting up Oh My Zsh theme

In addition to all other features of Oh My Zsh, I especially enjoy the themes collection that comes with the installation.

It enhances the terminal appearance and increases productivity.

By default, all Zsh themes installed to ~/.oh-my-zsh/themes directory:

ls ~/.oh-my-zsh/themes
15. Which terminal is better - Bash VS Zsh - Bash typo example - Zsh - Oh My Zsh themes location

The default theme for the Zsh shell is “robbyrussell“.

To modify this theme, update the ~/.zshrc file and set ZSH_THEME variable value with the name of the theme you want to use:

nano ~/.zshrc

Try to use crunch, for example:

15. Which terminal is better - Bash VS Zsh - Bash typo example - Zsh - Oh My Zsh theme change

Now, use the following command to install powerline fonts:

apt-get install -y powerline fonts-powerline
1. How To Customize your Zsh shell on Ubuntu - Zsh - Install powerline fonts

To apply theme changes, execute the following command:

source ~/.zshrc

Setting up Oh My Zsh plugins

Oh My Zsh supports a large number of plugins and it is easy to set them up. If you’d like to start using any plugin, you need to download the plugin kit and add its name to the plugins variable in ~/.zshrc file. 

The default installation of Zsh comes with a git plugin which allows you to get information about branch, commits and status of your local git repository.

2. How To Customize your Zsh shell on Ubuntu - Zsh - plugins - git

As an example, let’s add two additional useful plugins:

To install first plugin, just clone it to the Zsh plugins directory:

git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions
3. How To Customize your Zsh shell on Ubuntu - Zsh - plugins - install zsh-autosuggersions

Same thing should be done for the second plugin:

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
4. How To Customize your Zsh shell on Ubuntu - Zsh - plugins - install zsh-syntax-highlighting

Now, add the names of downloaded plugins in the plugin parameter of ~/.zhsrc file:

nano ~/.zshrc

Modify the plugins variable:

5. How To Customize your Zsh shell on Ubuntu - Zsh - plugins configuration

To apply the changes, use source command:

source ~/.zshrc

Setting up Oh My Zsh updates

Every two weeks Oh My Zsh automatically checks up for the updates.

You can also disable this function by setting the DISABLE_AUTO_UPDATE variable to true.

Or you can change the update interval time by changing the value of UPDATE_ZSH_DAYS.

6. How To Customize your Zsh shell on Ubuntu - Zsh - update schedule

For  manual update, use the following command:

omz update
7. How To Customize your Zsh shell on Ubuntu - Zsh - omz update

To enable syntax highlighting, add it to ~/.zshrc:

echo "source $HOME/.zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ~/.zshrc
8. How To Customize your Zsh shell on Ubuntu - Zsh - enable syntax highlighting

Finally, apply the changes:

source ~/.zshrc

Summary

In this article, we covered the basics of customizing your Zsh shell in Ubuntu Linux using Oh My Zsh. We showed how to set up Zsh themes, install additional powerline fonts, enable syntax highlighting, install plugins, and do automatic and manual Oh My Zsh updates.

We hope you’ve found this article useful. If so, please, help us to spread it to the world!

Like this article?

Share on facebook
Share on Facebook
Share on twitter
Share on Twitter
Share on linkedin
Share on Linkdin
Share on pinterest
Share on Pinterest

Leave a comment