author Magesh

Setting up the Linux shell

Magesh Ravi on April 24, 2022

In this post, you'll learn how to set up and use Z Shell or Zsh as your primary linux shell.

Before we get started, if you are a beginner Linux user, I suggest using KDE Neon OS. KDE Neon packages the latest KDE desktop alongside the long-term stable (LTS) Ubuntu release. Of all desktop environments/distros I have used, KDE Neon is the most stable and customisable while being the least resource hungry.

In case you have trouble following the steps mentioned below, please see the video at the end of this post for better understanding.

Let's get started.

Table of contents

Git

Git is the most popular version control system available today. As a developer, git is a must-have utility in your toolkit.

sudo apt-get install git

Zsh

Zsh is an interactive shell that offers superior command line auto-completion in your terminal. Hundreds of plugins like git, docker, and docker-compose make your life easier as a CLI user.

# install zsh
sudo apt install zsh

# verify installation
zsh --version

# make zsh your default shell
chsh -s $(which zsh)

Logout and log back in for the changes to take effect.

# test if zsh is your default shell
echo $SHELL

# check version
$SHELL --version

Oh-My-Zsh

OhMyZsh is an open-source framework for managing your Zsh configuration. You could configure your Zsh yourself. But I suggest using OhMyZsh as a starting point and building on top of that.

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

OhMyZsh comes with loads of bundled plugins. You can check the wiki to see what's currently available. To use a plugin, you'll have to enable it in the .zshrc file usually located in your $HOME folder. Open it with your favourite text editor.

nano ~/.zshrc

Update your base configuration to,

plugins=(
  git
)

Save and exit. For the plugins to take effect, reload your zsh config file.

source ~/.zshrc

Zsh-Git

Zsh Autosuggestions

This plugin suggests commands as you type, based on your command history. It's fast and one of the best plugins not bundled with Oh-My-Zsh.

Clone the repository into $ZSH_CUSTOM/plugins (by default ~/.oh-my-zsh/custom/plugins)

git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

Then add the plugin to the list of plugins inside .zshrc.

plugins=(
  git
  zsh-autosuggestions
)

Save and exit. Reload the configuration file.

zsh-autosuggestions

Zsh Syntax Highlighting

This plugin provides syntax highlighting in terminal as you type.

Clone the repository into $ZSH_CUSTOM/plugins folder,

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

Add the plugin inside .zshrc

plugins=(
  git
  zsh-autosuggestions
  zsh-syntax-highlighting
)

Save and exit. Reload the configuration file.

Zsh Syntax Highlighting

Video