Install and Setup Oh-My-Zsh on Ubuntu System
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)"
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
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.
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.
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.
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
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
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.
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.
Please login or create new account to add your comment.
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
please Help
Open terminal -> Edit -> Preferences
and in line "Custom command" write /usr/bin/bash
Hopefully, it will solve this issue.
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.
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.