Unlock the Power: Elevate Your Shell Experience with ZSH over Bash

Unlock the Power: Elevate Your Shell Experience with ZSH over Bash

Discover the power of ZSH over Bash: a versatile shell with enhanced features and stunning visual appeal Upgrade your Linux experience with ZSH and explore its installation on various distributions, along with the usage of Oh My Zsh themes

Key Takeaways

ZSH, which is an enhanced version of the Bourne Shell, provides a range of new functionalities including automatic cd, spelling correction, themes, and plugins.

To install ZSH on Ubuntu or any other Debian-based distribution, simply execute the command "sudo apt install zsh" and then change the default shell by running "chsh -s $(which zsh)."

To install ZSH, a popular alternative to the Bash shell on Fedora, execute the following command in the Terminal: "sudo dnf install zsh". Once installed, switch to ZSH by entering the command "zsh".

What is ZSH?

ZSH, known as the Z shell, is an enhanced iteration of the Bourne Shell (sh) that offers added functionalities, along with the ability to utilize plugins and themes. Relying on the same shell as Bash, ZSH shares a multitude of features, making the transition seamless.

ZSH vs. Bash: The Important Differences

ZSH has too many features to list here, some just minor improvements to Bash, but here are some of the major ones:

Automatic cd: Just type the name of the directory

Recursive path expansion: For example "/u/lo/b" expands to "/usr/local/bin"

Automatic Syntax Highlighting enables color-coded words, file extensions, and other visible elements in the Terminal.

With the feature of Spelling correction and approximate completion, ZSH will automatically fix minor typing mistakes in directory names for you.

ZSH offers extensive support for plugins and themes, making it one of its standout features. In this section, our main focus will be on exploring this impressive functionality. Depending on your Linux distribution, the method to install ZSH may differ, but it is usually included as a default package in your package manager.

Install ZSH on Ubuntu (or any Debian Distribution)

To install ZSH on Ubuntu, or any other Debian-based distro, open up the Terminal, then run:

sudo apt install zsh

Unlock the Power: Elevate Your Shell Experience with ZSH over Bash

Confirm that zsh has been installed correctly by running zsh --version in the console. You should see something like this:

Unlock the Power: Elevate Your Shell Experience with ZSH over Bash

Now that ZSH has been downloaded and installed correctly, we need to change the default shell from Bash to ZSH. Run:

chsh -s $(which zsh)

Unlock the Power: Elevate Your Shell Experience with ZSH over Bash

To ensure successful installation, simply restart your PC at this juncture. Upon reopening the Terminal, you will encounter a prompt presenting various configuration options for ZSH. Now that you have ZSH installed, you can begin incorporating themes and utilizing plugins. The process of accomplishing this is detailed in the final two sections of the article.

Install ZSH on Fedora

To install ZSH on Fedora, open up the Terminal, then run:

sudo dnf install zsh

Unlock the Power: Elevate Your Shell Experience with ZSH over Bash

You'll need to confirm you want to install it and then wait for everything to finish up. Once it is done, execute the following command to switch your shell to ZSH:

zsh

Unlock the Power: Elevate Your Shell Experience with ZSH over Bash

As soon as you run zsh you'll be prompted to go through some of the basic options zsh lets you customize.

Unlock the Power: Elevate Your Shell Experience with ZSH over Bash

Install ZSH on Other Linux Systems

Generally speaking, it is recommended to use your distros default package manager for installing ZSH. This is because ZSH is usually included by default in most repositories (repos). However, if for some reason it is not available, you can always download the source code and install it. Furthermore, the ZSH GitHub provides installation instructions for the most popular Linux distros.

Install Oh My Zsh

The installation of Oh-My-Zsh is made easy with a simple script that can be run.

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

You'll see a message in the Terminal if everything goes correctly:

Unlock the Power: Elevate Your Shell Experience with ZSH over Bash

From there, you can enable and disable plugins by adding them to your .zshrc file, located in your ~ directory.

Unlock the Power: Elevate Your Shell Experience with ZSH over Bash

You can get a full list of plugins on the Oh-My-Zsh repository.

How to Use ZSH Themes

Among the wide variety of themes available, powerlevel9k stands out as the most impressive. It enhances the user experience with features like a right-aligned information box, seamless integration with git and command history, extensive customization options, and a sleek interface inspired by the powerline plugin for vim. For optimal results with powerlevel9k (or any ZSH theme), it is recommended to use iTerm on macOS or any terminal that supports 24-bit color.

To install powerlevel9k with Oh-My-Zsh, simply clone the repository into the .oh-my-zsh custom themes folder by executing this command:

git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k

Then you need to enable it in .zshrc. Open the ".zshrc" file with Vi (or use your preferred editor), and add the following line.

ZSH_THEME="powerlevel9k/powerlevel9k"

Unlock the Power: Elevate Your Shell Experience with ZSH over Bash

After that, run source .zshrc to reload the configuration file, and you should see the changes applied.

Customize the default prompt by defining POWERLEVEL9K_LEFT_PROMPT_ELEMENTS in your .zshrc. Below is my version with a simple prompt:

POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs dir rbenv)

POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(root_indicator background_jobs status load)

Unlock the Power: Elevate Your Shell Experience with ZSH over Bash

You can find the full documentation for powerlevel9k on the repo.

Linux Commands

Files

tar · pv · cat · tac · chmod · grep · diff · sed · ar · man · pushd · popd · fsck · testdisk · seq · fd · pandoc · cd · $PATH · awk · join · jq · fold · uniq · journalctl · tail · stat · ls · fstab · echo · less · chgrp · chown · rev · look · strings · type · rename · zip · unzip · mount · umount · install · fdisk · mkfs · rm · rmdir · rsync · df · gpg · vi · nano · mkdir · du · ln · patch · convert · rclone · shred · srm · scp · gzip · chattr · cut · find · umask · wc · tr

Processes

alias · screen · top · nice · renice · progress · strace · systemd · tmux · chsh · history · at · batch · free · which · dmesg · chfn · usermod · ps · chroot · xargs · tty · pinky · lsof · vmstat · timeout · wall · yes · kill · sleep · sudo · su · time · groupadd · usermod · groups · lshw · shutdown · reboot · halt · poweroff · passwd · lscpu · crontab · date · bg · fg · pidof · nohup · pmap

Networking

netstat · ping · traceroute · ip · ss · whois · fail2ban · bmon · dig · finger · nmap · ftp · curl · wget · who · whoami · w · iptables · ssh-keygen · ufw · arping · firewalld