Install and Setup Zsh

Jan 10, 2025

Zsh (Z shell) is a powerful and highly customizable shell designed for interactive use and scripting. It includes many features like advanced tab completion, themes, and plugins, making it a popular choice for developers and power users.

This tutorial will guide you through the steps to install and configure Zsh on your system.


Step 1: Install Zsh

On Debian/Ubuntu

sudo apt update
sudo apt install zsh

On macOS (using Homebrew)

brew install zsh

Step 2: Change Default Shell to Zsh

Linux/macOS

  1. Change the default shell:

    chsh -s $(which zsh)
  2. Log out and log back in for the change to take effect.


Oh My Zsh is a popular Zsh framework that simplifies plugin and theme management.

Install Oh My Zsh

Run the following command:

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

Step 5: Customize Zsh

Change Theme

  1. Open the Zsh configuration file:
    vim ~/.zshrc
  2. Locate the ZSH_THEME variable and change its value to your desired theme:
    ZSH_THEME="agnoster"
  3. Save the file and restart Zsh:
    source ~/.zshrc

Add Plugins

  1. Install the necessary plugins:
    git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
    git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting
    
  2. Open the Zsh configuration file:
    vim ~/.zshrc
  3. Add plugins to the array:
    plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
  4. Save and reload Zsh:
    source ~/.zshrc

Congratulations! You have successfully installed and configured Zsh. Enjoy your enhanced terminal experience!

Masred