Linux

How to ZSH and Oh-my-zsh Settings on Linux

0
How to ZSH and Oh-my-zsh Settings on Linux

Z shell or zsh is an interactive UNIX shell and a powerful command line interpreter for scripting languages, including shell scripting. Zsh was developed by ‘Paul Fastad’ since 1990, and the name ‘zsh’ comes from professor Yale Zong Shao.

Z-Shell has become one of the most popular shells for the Linux operating system. It is rich in features and easy to configure and adjust. Here are some important zsh functions:

  • Auto-complete commands
  • Improved variable handling
  • Spell correction
  • History of joint orders
  • Kill tab completion
  • Setting environment variables is easy
  • Can be adjusted

Geez

Oh-my-zsh is an open-source framework for managing ZSH, shell Z. There are also other frameworks for Z shell, such as prezto, Zgen, Antigen, etc. In this tutorial, we use ‘oh-my-zsh’ for our zsh configuration.

Oh-my-zsh is a community-based framework with many functions. It comes with a design that can be customized and has an extensive catalog of plugins intended for administrators and system developers.

In this tutorial we show you how to install Z-Shell or zsh on Ubuntu Linux and CentOS. Then we configure the oh-my-zsh framework to manage zsh. We will also show you how to change the zsh theme and activate the plugin.

Precondition

  • Linux – Ubuntu 20.04 or CentOS 8
  • Rooting privileges

What we will do

  • Install and configure ZSH
  • Install and configure the Oh-my-zsh framework
  • Change the default theme
  • Activate the oh-my-zsh plugin

Step 1 – Install and configure ZSH

In this step, we will install the Z shell from the repository, and then configure the user to use the Z shell as the default theme. Basically, the default shell on Ubuntu and CentOS is bash, so we will configure the root user to use zsh as the default shell.

To install zsh from the repository, use the following command.

On Ubuntu:

apt install zsh>

On CentOS:

dnf install zsh

After the installation is complete, change the default shell from the root user to zsh with the chsh command below.

On Ubuntu:

chsh -s /usr/bin/zsh root

On CentOS:

chsh -s /bin/zsh root

Now log out from the root user, log in again, and you will get the zsh shell.

Check the current shell used with the command below.

echo $SHELL

The output must be zsh. This is the result on Ubuntu.

1

And this is the result at CentOS.

2

Z shell zsh has been installed.

Step 2 – Install and configure the Oh-my-zsh framework

So the Z shell is now installed on the system. Next, we want to install the oh-my-zsh framework to manage zsh zsh. Oh-my-zsh provides an installer script to install the framework, and we need to install a number of other packages that are needed, including wget to download the installer script and Git to download the oh-my-zsh shell from GitHub.

So the first step is to install wget and git on the system. Here are the commands you need to run:

On Ubuntu:

apt install wget git

On CentOS:

dnf install wget git

Now download the installer script and run it.

wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh

Results should be similar to those shown below.

3

So, oh-my-zsh is installed in the home directory ‘~ / .oh-my-zsh’.

Next, we need to create a new configuration for zsh. Like the Bash shell, which has a configuration named ‘.bashrc’, for zsh, we need the ‘.zshrc’ configuration file. It is available in the oh-my-zsh template directory.

Copy the .zshrc.zsh-template configuration file to the .zshrc home directory and apply the configuration by running the source command, as shown below.

cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
source ~/.zshrc

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

The following results on Ubuntu.

4

And this is what you will see on CentOS.

5

Step 3 – Change the default theme

The default .zshrc configuration provided by oh-my-zsh uses the ‘robbyrusell’ theme. In this step, we will edit the configuration and change the default theme.

The Oh-my-zsh framework provides many themes for your zsh shell, open the link below to see the available options.

https://github.com/robbyrussell/oh-my-zsh/wiki/Themes

Or, you can go to the ‘themes’ directory and see the list of available themes.

cd ~/.oh-my-zsh/themes/
ls -a

6

To change the default theme, we need to edit the .zshrc configuration file. Edit the configuration with the vim editor.

vim ~/.zshrc

Choose a zsh theme – say the ‘risto’ theme.

Then change ‘ZSH_THEME’ line 10 to the ‘risto’ theme as below.

ZSH_THEME='risto'

Save and exit.

Now, reload the configuration. Zshrc and you will see that the ‘risto’ theme is currently used as your shell theme.

source ~/.zshrc

The result is on Ubuntu.

7

Results on CentOS.

8

So this way, you can apply the new oh-my-zsh theme.

Step 4: Activate the Oh-my-zsh plugin

Oh-my-zsh offers an amazing plugin. There are many plugins for our environment, aimed at developers, system admins, and everyone.

The default plugin is in the ‘plugins’ directory.

cd ~/.oh-my-zsh/plugins/
ls -a

9

In this step, we will change zsh using the ‘oh-my-zsh’ framework by activating several plugins. To activate the plugin, we need to edit the .zshrc configuration file.

Edit the .zshrc configuration file.

vim ~/.zshrc

Open the ‘plugins’ line 54 and add the plugins you want to activate in the bracket (). For example, here are the changes that I made in my case:

plugins=(git extract web-search yum git-extras docker vagrant)

Following are the results when using the ‘extract’ plugin – You can extract zip and tar files using the ‘extract’ command.

10

Yum command – info yum with only the ‘yp’ command.

11

Vagrant plugin for auto-complete commands.

12

In closing, the Z shell, as well as the oh-my-zsh framework, have been installed. Additionally, the default oh-my-zsh theme has been changed with several plugins activated.

How to integrate the ONLYOFFICE editor with the Nuxeo Platform

Previous article

How to change language in Outlook

Next article

You may also like

More in Linux