How to install and configure Zsh on Linux

Rphl_Mstl
Rphl_Mstl
Jul 6 · 3 min read

Bash (Bourne Again Shell) is the default command-line shell on Arch Linux. Zsh (Z Shell) is a powerful shell that operates as both an interactive shell and as a scripting language interpreter.

Zsh on Tilix ‘Quake’ drop-down terminal

Before starting check the shell currently in use:

> echo $SHELL
/usr/bin/bash

1. Z Shell

Install the zsh package:

> sudo pacman -S zsh

Test it by running zsh in your terminal. If you were using bash, you’ll switch to the zsh prompt. The prompt model will be different, since you’re using a different config file, not your classic .bashrc:

22:15 rphl ~ : echo $SHELL
/usr/bin/bash
22:15 rphl ~ : zsh

➜ ~

For basic configuration, run the following command:

➜  ~ zsh /usr/share/zsh/functions/Newuser/zsh-newuser-install -f

Follow the recommendations, save and exit.

2. Oh-My-Zsh & plugins

Now, let’s install a powerful additional program: Oh My Zsh

A delightful community-driven (with 1,300+ contributors) framework for managing your zsh configuration. Includes 200+ optional plugins, over 140 themes to spice up your morning, and an auto-update tool so that makes it easy to keep up with the latest updates from the community.

This framework will easily make Zsh friendlier by improving its usability, through plugins and themes.

Syntax highlight

zsh, wget and git should be installed first. Install the program:

➜  ~ sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

I recommend installing 2 additional plugins that we’ll activate later through OMZ configuration file :

zsh-syntax-highlighting

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

zsh-autosuggestions

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

2. Configuring Zsh

For advanced configuration, modify the ~./zshrc config file.

  • Plugins (list of plugins): OMZ comes with a large list of plugins waiting to be activated by entering their names in the plugins section, as follow. In this section, add the name of the 2 additional plugins we installed manually, in bold:
plugins=(
archlinux
git
history-substring-search
colored-man-pages
zsh-autosuggestions
zsh-syntax-highlighting

)
  • Theming (list of themes): enter the name of your favorite theme in the ZSH_THEME section:
ZSH_THEME="robbyrussell"

Copy your aliases from the .bashrc file into .zshrc, as well as other commands you may have created.

Tip: Apply the changes without needing to logout and then back in by running source ~/.zshrc.

History & Ranger

4. Make Zsh default

➜  ~ chsh -s $(which zsh)

Log out and log in back for the changes to take effect.

Enjoy!

Tech notes and Geek stuff

Tech & Geek stories, about Linux systems, Raspberry projects, FOSS, Photos & image manipulation, Voxels and pixel art

Rphl_Mstl

Written by

Rphl_Mstl

OS explorer, UI & UX passionate, Voxels crafter, code lover, Video Games player, Podcasts listener, Music amateur // Digital Publishing professional

Tech notes and Geek stuff

Tech & Geek stories, about Linux systems, Raspberry projects, FOSS, Photos & image manipulation, Voxels and pixel art

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade