Z Shell or ZSH is one of the most powerful interactive login shell for Linux and Unix-based systems. It's built on bash and provides extended features over it. It also provides the ZSH scripting language which is closely similar to bash.
If you spend a lot of time on your terminal, you will know the need to quick and convenient features that makes your life easy. Luckily, zsh provides both of the above while providing a minimal learning curve.
Let's dive in.
Installing ZSH and git
Although zsh is default in latest versions of macOS, most Linux distributions still ship bash as the default shell.
Hence before using oh-my-zsh framework, its good to ensure you have ZSH installed.
On Debian and Debian-based distributions, we can run the command:
sudo apt-get upate && sudo apt-get install zsh git
On REHL/Fedora/CentOS
sudo yum install zsh git
On Arch/Manjaro
sudo pacman -S zsh git
On SUSE
sudo zypper install zsh git
Once installed, you can change the default shell to ZSH with the command:
Change default shell to ZSH
You can change the default shell to zsh with the command:
chsh -s /bin/zsh
Installing oh-my-zsh framework
oh-my-zsh
is a free and open-source framework for zsh shell. It comes packed with features and customisations using the the native zsh fi configuration file.
oh-my-zsh also allows you to add plugins for support for various operations such as version control, node.js, python, and more.
Before you can use oh-my-zsh on your system, run the commands below to install it:
cURL
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Wget
sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
The commands above will clone and install the oh-my-zsh framework on your system.
Setting Custom Theme
By default, oh-my-zsh will use a theme called robbyrussel
after the creator of oh-my-zsh.
To set a different theme, navigate into the resource below:
https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
Choose the theme you wish to apply and note down its name.
Next, edit the oh-my-zsh configuration file:
nano ~/.zshrc
Locate the ZSH_THEME
entry and replace the value with the name of the theme you selected.
For example, if you selected the theme arrow
:
ZSH_THEME="arrow"
Save and close the file.
To apply the changes, use the source
command:
source ~/.zshrc
Installing oh-my-zsh plugins
You can also install a custom plugin which comes with its own set of features for that tool. To locate the plugin you wish to use, navigate into the resource below:
https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins
For example, to add the python plugin,
Edit the .zshrc
file and add the plugin as shown:
plugins=(git,python)
The entry above enables the git
and python
plugins.
You can then use the source
command to reload the changes.
Ensure to read the instructions and the supported commands for your plugin.
Conclusion
In this article, you learned how you can customize your terminal using ZSH and oh-my-zsh framework. Feel free to explore the docs for more.
Share with your friends and leave a comment below.