
How to Install ZSH and Oh My ZSH on Linux
/ 2 min read
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
$ sudo apt install zsh- Fedora/CentOS/RHEL
$ sudo dnf install zsh- Arch Linux
$ sudo pacman -S zsh2. 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-completions5. Configure ZSH and Oh My ZSH
Edit ~/.zshrc file.
$ nano ~/.zshrcConfigure themes and plugins.
- Plugins
plugins=( git bgnotify zsh-autosuggestions zsh-completions fast-syntax-highlighting)- Themes
ZSH_THEME="agnoster"-
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_initzstyle :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