Skip to content

How to install Z Shell, change themes, and enable the autosuggestions plug-in on the command line interface (CLI)

Notifications You must be signed in to change notification settings

amarpan/how-to-install-and-configure-zshell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 

Repository files navigation

How to Install and Configure Z Shell in Linux

Written by Amar Panjwani
Technical Writer

Portfolio Badge
LinkedIn Badge
Stars Forks
Version

If you find this tutorial helpful, please consider giving it a ⭐

Z Shell (zsh) is a popular alternative to the default command line bash shell with improved features like recursive path expansion, automatic spelling correction, and plug-in and theme support.

This guide will walk you through the process of installing and configuring zsh, including how to change themes and enable the time-saving autosuggestions plug-in.

Before You Begin

Complete the following steps prior to getting started:

  1. Install Git:
sudo apt install curl wget git

Installation

  1. Install Zsh:
sudo apt install zsh
  1. Install Oh My Zsh:
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

You should now see the following prompt asking if you'd like to change your defaut shell to zsh. Type y to confirm.

Oh My Shell Configuration Prompt

Take a look at your new command line and you should notice the difference right away.

Zsh In Effect

Note:

If for any reason you need to switch back to the bash shell, use the following command:

chsh -s $(which bash)

Proceed to log out and back into your session for the change to take effect.

Run echo $SHELL to confirm the output is /bin/bash

Change Zsh Theme

By default, the zsh theme is set to robbyrussell, the name of the founder of Oh My Zsh. However, this is rather plain and there are over 100+ included themes with a wider assortment of colors and styles to choose from.

For example, here are 3 uniquely different themes to choose from:

  1. jonathan

Jonathan Theme Preview

  1. xiong-chiamiov

Xiong Chiamiov Theme Preview

  1. agnoster

Agnoster Theme Preview

Follow these steps to change themes to jonathan:

  1. Open your zsh configuration file:
vi ~/.zshrc
  1. Press i to enter Insert Mode.

  2. Change the ending of the line reading:

ZSH_THEME="robbyrussell"

to

ZSH_THEME="jonathan"
  1. Press ESC to leave Insert Mode and enter Command Mode.

  2. Type :wq + ENTER to save and quit.

  3. Reload the command line:

source ~/.zshrc
  1. Check out your newly themed command line and repeat steps 1-6 with a few more themes to find the best fit.

  2. To see the full list of locally available zsh themes, follow these steps:

    a. Change directories to the zsh themes folder:

    cd ~/.oh-my-zsh/themes
    

    b. List the names of all the available themes:

    ls
    

Enable Autosuggestions

The autosuggestions plug-in is quite possibly the single most time-saving tool when coding. Instead of having to type the same command over and over again in full, this plug-in automatically suggests the rest of your command as you are typing, without even having to press TAB.

For example, instead of having to type git push origin main every single time you wish to push a new commit, you can instead type git push and the command line will automatically show a preview of the rest of the suggested command based on your shell's history.

Auto-Complete Plug-in Preview

Follow these steps to install and enable the autosuggestions plug-in:

  1. Change directories to the oh-my-zsh plug-ins location:
cd ~/.oh-my-zsh/plugins/
  1. Clone the autosuggestions plugin packages:
git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions
  1. Edit the zsh configuration file:

    a. Type vi ~/.zshrc

    b. Press i to enter Insert Mode.

    c. Update the line beginning with plugins=(git) to plugins=(git zsh-autosuggestions)

    d. Press ESC to leave Insert Mode and enter Command Mode.

    d. Type :wq + ENTER to save and quit.

  2. Reload the command line for the changes to take effect:

source ~/.zshrc
  1. Try it out! Start typing a command you know to be in your shell's history and watch as zsh offers autosuggestions. After seeing a suggestion that you'd like to approve, press the Right Arrow key to accept it.

More Information

You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.

***If you found this tutorial helpful, please consider giving it a ⭐

Copyright ©️ 2021-2022

More Tutorials from Amar Panjwani

How to Create a GitHub Profile

How to Write a README

How to Use the Command Line Vim Text Editor

About

How to install Z Shell, change themes, and enable the autosuggestions plug-in on the command line interface (CLI)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published