Installing and Setting Up Oh My Zsh on Ubuntu
Introduction
After successfully installing Zsh, the next step is often installing Oh My Zsh.
Oh My Zsh is a popular open-source framework for managing Zsh configurations. It simplifies customization by providing themes, plugins, aliases, and useful productivity features without requiring extensive manual configuration.
This guide explains the prerequisites, installation process, and initial setup of Oh My Zsh on Ubuntu while breaking down every command used during the process.
What is Oh My Zsh?
Oh My Zsh is a community-driven framework built on top of Zsh.
It helps users:
• Manage Zsh configurations easily
• Install and use themes
• Enable plugins
• Improve terminal productivity
• Customize the shell without editing complex configuration files
Instead of manually configuring every feature, Oh My Zsh provides a ready-to-use environment that can be customized later.
Prerequisites
Before installing Oh My Zsh, the following requirements should be met:
Requirement 1: Zsh Must Be Installed
Verify that Zsh is installed.
zsh --version
Understanding the Command
• zsh = Runs the Zsh executable.
• --version = Displays the installed version.
Example output:
zsh 5.9
If a version number is displayed, Zsh is installed successfully.
Requirement 2: Git Must Be Installed
Oh My Zsh uses Git to download and manage its files.
Check whether Git is installed:
git --version
Understanding the Command
• git = Runs the Git executable.
• --version = Displays the installed Git version.
Example output:
git version 2.43.0
If a version number appears, Git is already installed.
Installing Git (If Not Installed)
If Git is not installed, install it using:
sudo apt install git -y
Understanding the Command
• sudo = Executes the command with administrator privileges.
• apt = Ubuntu package manager.
• install = Installs a package.
• git = Package name.
• -y = Automatically confirms installation prompts.
This command downloads and installs Git.
Verifying Git Installation
After installation, verify Git again:
git --version
Successful installation displays the installed version.
Installing Oh My Zsh
Once both Zsh and Git are available, Oh My Zsh can be installed.
Execute the following command:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/
tools/install.sh)"
Understanding the Installation Command
At first glance, this command may look complicated. Breaking it into smaller parts makes it easier to understand.
Part 1: curl
curl URL
What is curl?
curl is a command-line utility used to transfer data from servers and websites.
In this case, it downloads the Oh My Zsh installation script.
Part 2: curl Options
curl -fsSL URL
Understanding the Options
• -f = Fails silently if an error occurs.
• -s = Silent mode (hides progress information).
• -S = Displays errors even when silent mode is enabled.
• -L = Follows redirects automatically.
These options ensure that the installation script is downloaded cleanly.
Part 3: Command Substitution
$(curl -fsSL URL)
The $() syntax is called command substitution.
It means:
Execute the command inside the brackets and use its output.
The downloaded installation script becomes the output.
Part 4: sh -c
sh -c "command"
Understanding the Command
• sh = Shell interpreter.
• -c = Execute the command provided as a string.
In this installation process, sh executes the downloaded installation script.
Complete Flow
The entire command performs the following actions:
- Downloads the latest Oh My Zsh installation script from GitHub.
- Passes the script to the shell.
- Executes the installation automatically.
What Happens During Installation?
During installation, Oh My Zsh performs several actions automatically:
Creates the Oh My Zsh Directory
~/.oh-my-zsh
This directory contains:
• Themes
• Plugins
• Scripts
• Configuration files
Creates a Zsh Configuration File
~/.zshrc
If a .zshrc file already exists, Oh My Zsh creates a backup before making changes.
Changes the Default Theme
The default theme is usually:
robbyrussell
This theme adds useful information such as:
• Current directory
• Git branch information
• Prompt customization
Verifying Installation
After installation completes, verify that the Oh My Zsh directory exists.
ls -la ~/.oh-my-zsh
Understanding the Command
• ls = Lists files and directories.
• -l = Detailed view.
• -a = Shows hidden files.
• ~/.oh-my-zsh = Oh My Zsh installation directory.
If installation was successful, the directory contents will be displayed.
Understanding the .zshrc File
One of the most important files in a Zsh setup is:
~/.zshrc
This file controls:
• Themes
• Plugins
• Aliases
• Environment variables
• Terminal customization
Whenever a new terminal session starts, Zsh reads this file and applies the configured settings.
Reloading Configuration Changes
Whenever changes are made to .zshrc , they can be applied without restarting the terminal.
source ~/.zshrc
Understanding the Command
• source = Executes commands from a file in the current shell session.
• ~/.zshrc = Zsh configuration file.
This command reloads the configuration immediately.
Benefits of Using Oh My Zsh
After installation, users gain access to:
Themes
Customize the appearance of the terminal.
Plugins
Add functionality for tools such as:
• Git
• Docker
• Kubernetes
• Node.js
• Python
Better Productivity
Frequently used commands become easier to execute through aliases and shortcuts.
Easier Configuration
Most customizations can be performed by editing a single file:
~/.zshrc
Key Takeaways
Installing Oh My Zsh introduces several important Linux concepts:
• Git-based software installation
• Downloading scripts using curl
• Command substitution using $()
• Shell configuration files
• Theme and plugin management
Understanding these concepts provides a solid foundation for further terminal customization.