skip to content
Hiiruki's lab
Table of Contents

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
Terminal window
$ sudo apt install zsh
  • Fedora/CentOS/RHEL
Terminal window
$ sudo dnf install zsh
  • Arch Linux
Terminal window
$ sudo pacman -S zsh

2. Install Oh My ZSH

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

3. Change Default Shell to ZSH

Terminal window
$ sudo chsh -s $(command -v zsh)

4. Install Plugins

  • Fast Syntax Highlighting (F-Sy-H)

    Feature rich syntax highlighting for Zsh.

Terminal window
$ 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

Terminal window
$ 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.

Terminal window
$ 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.

Terminal window
$ nano ~/.zshrc

Configure themes and plugins.

  • Plugins
~/.zshrc
plugins=(
git
bgnotify
zsh-autosuggestions
zsh-completions
fast-syntax-highlighting
)
  • Themes
~/.zshrc
ZSH_THEME="agnoster"
  • Other Configurations (Optional)

  • Speeds up pasting when using zsh-autosuggestions

~/.zshrc
# 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
~/.zshrc
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.

Terminal window
$ exec zsh

References