Introduction

ZSH or Z shell is a shell designed for interactive use, although it is also a powerful scripting language. Many of the useful features of bash , ksh , and tcsh were incorporated into zsh; many original features were added.

Oh My Zsh is an open source, community-driven framework for managing ZSH configuration. It comes bundled with thousands of helpful functions, helpers, plugins, themes, and many more.

In this article, I will show you how to install ZSH and Oh My ZSH on Linux.

Steps

1. Install ZSH

Install with default package manager.

  • Debian/Ubuntu
sudo apt install zsh
  • Fedora/CentOS/RHEL
sudo dnf install zsh
  • Arch Linux
sudo pacman -S zsh

2. Install Oh My ZSH

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

3. Change Default Shell to ZSH

sudo chsh -s $(command -v zsh)

4. Install Plugins

  • Fast Syntax Highlighting (F-Sy-H)

    Feature rich syntax highlighting for Zsh.

git clone --depth 1 https://github.com/zdharma-continuum/fast-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/fast-syntax-highlighting
  • zsh-autosuggestions

    Fish -like fast/unobtrusive autosuggestions for zsh.

    It suggests commands as you type based on history and completions.

    Requirements: Zsh v4.3.11 or later

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

    Additional completion definitions for Zsh .

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

5. Configure ZSH and Oh My ZSH

Edit ~/.zshrc file.

nano ~/.zshrc

ⓘ NOTE
Use your preferred text editor.

Configure themes and plugins.

  • Plugins
plugins=(
        git
        bgnotify
        zsh-autosuggestions
        zsh-completions
        fast-syntax-highlighting
)

ⓘ NOTE

  • git is a default plugin. It is used to display the current git branch, git information, and other useful git-related workflow.
  • bgnotify is a default plugin. It is used to notify you when a background job completes.
  • Themes
ZSH_THEME="agnoster"

ⓘ NOTE
You can find more themes here .
For the external themes, you can find them here .

  • Other Configurations (Optional)

  • Speeds up pasting when using zsh-autosuggestions

# Speeds up pasting when using zsh-autosuggestions.
# See "https://github.com/zsh-users/zsh-autosuggestions/issues/238".
paste_init()
{
    OLD_SELF_INSERT="${${(s.:.)widgets[self-insert]}[2,3]}"
    zle -N self-insert url-quote-magic
}
paste_done()
{
    zle -N self-insert "$OLD_SELF_INSERT"
}
zstyle :bracketed-paste-magic paste-init paste_init
zstyle :bracketed-paste-magic paste-finish paste_done
  • Case-insensitive completion
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'

6. Restart ZSH

You can restart ZSH by closing and opening the terminal or by running the following command.

exec zsh

References