Back to blog
Apr 28, 2024
3 min read

Installing Zsh on Ubuntu

Set Zsh as the default shell, and use Oh My Zsh for customization.

Terminal on Ubuntu Linux

Photo by Gabriel Heinzer on Unsplash

Zsh, or Z Shell, is a popular Unix shell with features like auto-completion, advanced scripting capabilities, and customization options. This guide will show you how to install Zsh on Ubuntu, including installation on Ubuntu WSL (Windows Subsystem for Linux).

Step 1: Update the Package List

Open your terminal and ensure your package list is up to date by running:

sudo apt update
sudo apt upgrade

Step 2: Install Zsh

To install Zsh, enter the following command:

sudo apt install zsh

Step 3: Set Zsh as Your Default Shell

Once installed, you can set Zsh as your default shell with this command:

chsh -s $(which zsh)
  • After executing this command, you may need to log out and log back in for the changes to take effect.
  • You will need to restart your WSL instance for the changes to take effect.

Oh My Zsh is a framework for managing Zsh configurations, offering themes, plugins and other useful features. To install it, use the following command:

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
  • During the installation, you’ll be prompted to switch to Zsh if it’s not already your default shell.
  • Oh My Zsh will create a .zshrc configuration file in your home directory.

Step 5: Customize Zsh with Themes and Plugins

Once Oh My Zsh is installed, you can customize your Zsh experience with themes and plugins. Edit the .zshrc file to set your preferred theme and enable plugins. To open this file, use a text editor like nano:

nano ~/.zshrc

Look for the ZSH_THEME variable to change the theme. You can find a list of themes in the Oh My Zsh repository. To enable plugins, find the plugins line and add your preferred plugins.

Here are some suggestions:

  • Themes: Change the theme by editing the ZSH_THEME variable in .zshrc. For example, to use the “agnoster” theme, set ZSH_THEME="agnoster".
  • Plugins: You can enable plugins by editing the plugins array in .zshrc. Some commonly used plugins are git, docker, python, and node. For example, to enable git and python plugins, you would set plugins=(git python).

After making changes to .zshrc, remember to restart Zsh or source.