zsh

How to use plugins for ZSH

I think we can all agree that the shell is the one thing we all have in common as Unix/Linux geeks. Whether you are a system admin, DevOps, Hardware, or Penetration testing, you will have to use the terminal to accomplish your tasks.

In today’s tutorial, I want to show you how to install ZSH, make it the default shell and install the oh-my-zsh framework to customize and add more functionality to your shell using plugins.

Let us get started:

How to Install ZSH and Oh-My-ZSH Framework

ZSH is a popular shell usually available in the repositories of major Linux distributions. To install it, use your default package manager. For this example, I will use the apt package manager:

sudo apt-get update
sudo apt-get install zsh -y

Next, run ZSH for the initial setup and create a .zshrc config file.

To make ZSH your default shell, use the chsh command as:

chsh -s /usr/bin/zsh

Installing oh-my-zsh

Installing the oh-my-zsh framework is easy as executing a single line of command. If you want to know what the installer script does, you can download and review it, then execute it once you’re comfortable. Otherwise, use either of the commands below to install it:

sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"

To use cURL, enter the command:

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

Once you have oh-my-zsh is installed and activated, you can start customizing it by editing the .zshrc file in your home directory.

How to Activate Plugins

By default, oh-my-zsh comes packaged with a collection of plugins that you can activate to suit your needs. Some of them are simple aliases, but others are complex. The following link has a list of all supported plugins.

https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins

Once you find a plugin you wish to use, activate it by adding it to the plugin() array in the .zshrc file. For example, to activate the python, Vscode, git, and wp-CLI plugins, add the entries as shown below:

plugins=(python, git, vscode, wp-cli)

Save the file and source the .zshrc file to load the changes or launch a new shell session.

source ~/.zshrc

Conclusion

ZSH and Oh-my-zsh have a dedicated community that is constantly releasing new plugins, themes, and functions to make working with the shell easier. Feel free to visit the community forums to explore ways to customize your shell to fit your needs.

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list