Install and Setup Oh-My-Zsh on Ubuntu System

Harish Kumar · · 28988 Views

In this post, I will show you how to install ZSH (Z-Shell). Then, we set up the oh-my-zsh framework for managing ZSH. We will likewise show you how to change the ZSH theme and activate plugins.

The ZSH (the Z-Shell) has gotten one of the most well-known shells for the Linux operating system. It has many features and easy to configure and customize.

Oh-my-zsh is an open-source framework for managing ZSH, the Z shell. It comes with supportive functions, plugins, helpers, themes, and a couple of things that will improve you at the terminal. There are as of now 275+ plugins and 150 themes supported.

Step 1 - Install ZSH (Z-Shell)

To install ZSH, use the following commands.

sudo apt install zsh

Step 2 - Set default shell to ZSH (Optional)

After the installation is complete, it automatically selects ZSH as the default shell. You can use the following command to check the current shell:

echo $SHELL

In case if your default shell is not ZSH, then run the following command to make it default:

chsh -s $(which zsh)

# or

usermod -s $(which zsh) [username]

Step 3 - Install and configure the oh-my-zsh

So the Z shell is installed on the system. Next, we need to install the oh-my-zsh framework for managing the Z shell. Oh-my-zsh can be installed by either using the curl or wget command. So, make sure you have installed curl or wget in your system. And you also need Git for downloading oh-my-zsh shell from GitHub. So, if you have not already installed that, then you can install it using the following command:

sudo apt install curl wget git

Next, install Oh My Zsh via the command-line with either curl or wget as shown:

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

# or

sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Install and Setup Oh-My-Zsh on Ubuntu System

Oh-my-zsh is now installed on the system, and the Z shell has been configured for utilizing the oh-my-zsh framework with the default configuration.

Step 4 - Change default theme

The default theme of oh-my-zsh is robbyrusell. In this step, we will edit the .zshrc configuration and change the default theme.

The Oh-my-zsh framework provides many themes for your ZSH shell. You can go to the themes directory and see the list of available themes.

cd ~/.oh-my-zsh/themes/
ls -a
Install and Setup Oh-My-Zsh on Ubuntu System

To change the default theme, we need to edit the .zshrc configuration file. Let's open it in the vi editor:

vi ~/.zshrc

Let's say we want to use the theme candy. Then change the ZSH_THEME with candy theme as below.

ZSH_THEME="candy"

Save and exit. And reopen your terminal or reload configuration using the following command.

source ~/.zshrc

Now, you will see that the candy theme is used as your shell.

Install and Setup Oh-My-Zsh on Ubuntu System

My favorite ZSH theme is zsh-multiline. This does not come with ZSH themes. So, if you want to install it run the following command in the terminal:

git clone https://github.com/jan-auer/zsh-multiline.git ~/.oh-my-zsh/custom/themes/zsh-multiline

Now, to activate this theme edit the .zshrc configuration file:

vi ~/.zshrc

Then change the ZSH_THEME with zsh-multiline/multiline theme as below.

ZSH_THEME="zsh-multiline/multiline"

Save and exit. And reopen your terminal or reload configuration using the following command. 

source ~/.zshrc

Now, you should see the zsh-multiline theme used as your shell. 

Install and Setup Oh-My-Zsh on Ubuntu System

Here, you may notice that some icons are missing in this theme. To fix this you need to install powerline fonts in your system. Run the following command to install it:

sudo apt-get install powerline fonts-powerline

Now reopen your terminal and it should be working.

Install and Setup Oh-My-Zsh on Ubuntu System

If you don't want to display the username on the terminal, then add DEFAULT_USER=$USER in the .zshrc file as below.

DEFAULT_USER=$USER
Install and Setup Oh-My-Zsh on Ubuntu System

Step 5 - Enable oh-my-zsh plugins

Many plugins are supported by OH-MY-ZSH, and setting up a plugin is very simple. You should simply get the plugin package and add the plugin name in the plugins=() parameter on the .zshrc file. By default, git is the only plugin that is enabled after installation.

Default plugins are in the plugins directory.

cd ~/.oh-my-zsh/plugins/
ls -a
Install and Setup Oh-My-Zsh on Ubuntu System

Now let's install the two more plugins zsh-autosuggestions and zsh-Syntax-highlighting by cloning the packages.

git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting

To activate both these plugins, all you have to do is edit the .zhsrc file:

vi ~/.zshrc

Add the plugin name in plugins=() with a space between each plugin name.

plugins=(git zsh-autosuggestions zsh-syntax-highlighting)

Now, reload the configuration using source ~/.zshrc and both plugins will be enabled. And if you open any file (for example open the ~/.zshrc) you will see syntax highlighting as well. And on the terminal, it remembers the command previously used and suggests based on it.

Install and Setup Oh-My-Zsh on Ubuntu System

Removing OH-MY-ZSH in Ubuntu Linux

If you need to remove oh-my-zsh, run the command uninstall oh_my_zsh. It will remove all the necessary files and folders part of oh_my_zsh and return to the previous state. Reopen your terminal to see the changes.

uninstall oh_my_zsh

Conclusions

That is it for this article. We have explored what is oh-my-zsh, how to install and configure it. We have also seen its plugins and themes. Explore oh-my-zsh and share your experience with us.

4

Please login or create new account to add your comment.

4 comments
Imran Sultan
Imran Sultan ·

Hi Harish,

Thank you for sharing this article and also the YouTube guide.

I have installed oh-my-zsh together with tilix and running multiline theme.

But how do I get my terminal to look like yours? Please see my screenshot, my hostname appears in the beginning of the command line and I dont want it there.

Terminal

Harish Kumar
Harish Kumar ·

That is already explained in this article as well as in the video. For that you need to add DEFAULT_USER=$USER in the .zshrc file.

Shubham
Shubham ·

Hello Man! i'm Getting Unexpected error occured during launch of tilix.Failed to execute child process /usr/bin/bash No such file or Directory Tilix Installation

please Help

Harish Kumar
Harish Kumar ·

Open terminal -> Edit -> Preferences and in line "Custom command" write /usr/bin/bash

Hopefully, it will solve this issue.

You may also like:

How to Grant Passwordless `Sudo` for Specific Commands on Linux 🚀

Managing a self-hosted server or Virtual Private Server (VPS) often involves repetitive administrative tasks. Continuously entering your sudo password can quickly become tedious. (...)
Harish Kumar

Essential Linux Command Line Cheatsheets for Beginners and Advanced Users

The Linux command line is a powerful tool for managing your system efficiently. Whether you're a beginner exploring the terminal or an advanced user handling complex tasks, cheatsheets (...)
Harish Kumar

Understanding Linux File Permissions and Ownership

Linux file permissions are a critical cornerstone in the architecture of Linux systems, serving as a fundamental aspect of their security model. They meticulously define who can (...)
Harish Kumar

How To Install NVM (Node Version Manager) on Ubuntu System?

This tutorial will assist you with installing NVM on the Ubuntu machine. Additionally, allow you to install different node versions and other useful examples.
Harish Kumar

Install Laravel Valet Linux+ development environment on Ubuntu System

The official Laravel Valet development environment is great if you are an Apple user. But there is no official Valet for Linux or Window system.
Harish Kumar

10 Things to Do After Installing Ubuntu Operating System

In this article, I will show you 40 things you can do after installing Ubuntu on your system. This isn't restricted to a specific version of Ubuntu; you can follow these on any (...)
Harish Kumar