The Z shell, popularly known as zsh, is a Unix shell that can be used as an interactive login shell and as a command interpreter for shell scripting. Zsh is an extended Bourne shell with many improvements, including some features of Bash, ksh, and tcsh. Z shell is installable on all Linux distributions and many BSD systems. The packages are available in the OS upstream repositories.

If you don’t have zsh installed on your system check below commands that can be used:

### Install zsh on Ubuntu / Debian / Linux Mint / MX Linux / Kali Linux ###
$ sudo apt-get update
$ sudo apt-get install zsh

### Install zsh on CentOS 8/7 ###
$ sudo yum -y install epel-release
$ sudo yum -y install zsh

### Install zsh on Fedora ###
$ sudo dnf -y install zsh

### Install zsh on Arch Linux / Manjaro ###
$ sudo pacman -S zsh

Changing current logged in user shell to zsh

sudo usermod -s /usr/bin/zsh $(whoami)

Or specify username manually to change the shell for:

sudo usermod -s /usr/bin/zsh jkmutai

Confirm the shell set for the user:

$ getent passwd jkmutai

Enable Zsh completions

Download code from github.

git clone git:// ~/.zsh/zsh-completions

Include the directory in your $fpath, for example by adding in ~/.zshrc:

$ vim ~/.zshrc
fpath=(~/.zsh/zsh-completions/src $fpath)
$ exit

Enable zsh-autosuggestions in Zsh Shell

Once the shell has been set for the user, you can now enable zsh autosuggestions. The requirement for this autosuggestions is Zsh v4.3.11 or later.

You can check the version of Zsh using the following command:

$ zsh --version
zsh 5.5.1 (x86_64-redhat-linux-gnu)

With Zsh autosuggestions set, as you type commands, you will see a completion offered after the cursor in a muted gray color. The color can be changed by setting the ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE variable.

Manually install zsh-autosuggestions

For manual installation download the code from Github using git command line tool:

git clone ~/.zsh/zsh-autosuggestions

If you don’t have git install with the following commands:

# CentOS / Fedora #
$ sudo yum -y install git

# Ubuntu / Debian #
$ sudo apt install git

# Manjaro / Arch Linux #
$ sudo pacman -S git

Then add the following to your ~/.zshrc file.

echo "source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh" | tee -a ~/.zshrc

Start a new terminal session:

$ exit

For Oh My Zsh users

If you are an Oh My Zsh user, clone this repository into $ZSH_CUSTOM/plugins directory:

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

Then add the plugin to the list of plugins for Oh My Zsh to load inside ~/.zshrc file.

$ vim ~/.zshrc

Start a new terminal session to start using zsh autosuggestions

For Antigen users

Add the following to your ~/.zshrc:

antigen bundle zsh-users/zsh-autosuggestions

Then start a new terminal session.

Visit the zsh-autosuggestions configuration sections to understand how you’ll configure and tune the components to give ultimate Zsh experience.

Bonus – Enable Syntax Highlighting on Zsh

The syntax highlighting for zsh enables highlighting of commands whilst they are typed at a zsh prompt into an interactive terminal. This helps in reviewing commands before running them, particularly in catching syntax errors.


git clone
echo "source ${(q-)PWD}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc

Then, enable syntax highlighting in the current interactive shell:

source ./zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

For Oh My Zsh users you can also use:

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

# Then Activate the plugin in ~/.zshrc
plugins=( [plugins...] zsh-syntax-highlighting)

For more details check the zsh syntax highlighting project page.

Similar guides:

Using TLDR – Best Linux Command Line Help Pages and Cheats

Grep vs Awk vs Sed Commands in Linux

How To Install Gitea on Amazon Linux 2