Why switch to Zsh and Oh-My-Zsh ?
Modern terminal users expect faster workflows, better history search, auto-suggestions, and a customizable prompt. Zsh, paired with Oh My Zsh, provides these improvements immediately.
What Zsh improves over Bash ?
| Shell | Description | Key Features |
|---|---|---|
| Zsh (Z Shell) | A powerful Unix shell, similar to Bash but more feature-rich. | Smarter history search, robust completion, plugin ecosystem, customizable prompt. |
| Oh My Zsh | A framework built on Zsh. It does not replace Zsh; it enhances it. | 200+ plugins, 100+ themes, aliases, auto-completion, easy configuration. |
Installation Workflow (High-Level Overview)
flowchart TD
A[Start Terminal] --> B[Install Zsh]
B --> C[Set Zsh as Default Shell]
C --> D[Install Oh My Zsh]
D --> E[Install Plugins]
E --> F[Configure .zshrc]
F --> G[Apply Theme]
G --> H[Restart Shell]
H --> I[Enhanced Terminal Experience]
Step 1: Update Your Linux System
Before installing Zsh, refresh package lists and upgrade current packages.
This ensures compatibility and avoids dependency issues.
sudo apt update -y && sudo apt upgrade -y
Step 2: Install Zsh
sudo apt install zsh -y
# Verify installation
which zsh
# Expected output: /bin/zsh
Step 3: Make Zsh Your Default Shell
Important: Log out and log back in for changes to apply. If your terminal still opens in Bash, check the troubleshooting section below.
chsh -s /bin/zsh
Step 4: Install Oh-My-Zsh Framework
The official installer downloads and configures Oh My Zsh automatically.
Below script creates:
~/.oh-my-zsh/directory.- Updated
~/.zshrcconfiguration. - Core initialization scripts.
# Oh-my-zsh automatic script
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Step 5: Initial post-installation setup
5.1 Import old Bash Hhistory (Recommended)
Zsh can start suggesting your previously used commands immediately.
Note:
- If
.zsh_historyalready contains Zsh metadata, you can ignore this step as it will overwrite zsh history. - For safety, back it up:
cp ~/.zsh_history ~/.zsh_history_backup
cp ~/.bash_history ~/.zsh_history
fc -R ~/.zsh_history
5.2 Improve autosuggestion visibility
Some terminal themes make suggestions hard to see.
Customize the highlight color:
# Place this BEFORE plugin loading in ~/.zshrc
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#ff00ff"
Step 6: Recommended Plugins
The Oh-My-Zsh plugin ecosystem greatly boosts productivity.
Here is some of the useful plugins to start with
| Plugin | Purpose | Benefit | Difficulty |
|---|---|---|---|
git | Git helpers | Faster version control | Easy |
zsh-autosuggestions | Predictive text | Saves keystrokes | Easy |
zsh-syntax-highlighting | Color-coded validation | Prevents errors | Easy |
docker | Docker shortcuts | Faster container workflow | Easy |
history-substring-search | Fuzzy history search | Fish-like behavior | Medium |
vi-mode | Vim-style navigation | Ideal for Vim users | Medium |
6.1 Install auto-suggestions plugin
git clone https://github.com/zsh-users/zsh-autosuggestions \
${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
Enable it in .zshrc:
# Open zsh config file
nano ~/.zshrc
# Conf
plugins=(git zsh-autosuggestions)
# Reload the changes
source ~/.zshrc
How Auto-Suggestions work
sequenceDiagram
participant U as User
participant Z as Zsh
participant A as Autosuggest
participant H as History
U->>Z: Types text
Z->>A: Request suggestion
A->>H: Search history
H-->>A: Return best match
A-->>U: Show faded suggestion
U->>Z: Accept (Right Arrow)
Step 7: Choose and apply a Zsh theme
Themes define your prompt layout, icons, colors, and performance.
Factors to consider
- Minimal vs modern vs powerline
- Font compatibility (some require Nerd Fonts / Powerline fonts)
- Prompt speed (complex themes load slower)
- Information density (git, directory, time, exit code, etc.)
Popular Built-in themes
| Theme | Style | Recommended For | Notes |
|---|---|---|---|
| agnoster | Powerline | Modern UI | Requires Powerline fonts |
| robbyrussell | Default | Beginners | Fast and clean |
| powerlevel10k | Highly customizable | Power users | Ultra-fast, extra install |
| avit | Minimal | Laptops | Lightweight |
| bureau | Simple | Servers | Stable and readable |
Applying a theme
Edit .zshrc:
ZSH_THEME="agnoster"
source ~/.zshrc
Try different themes, until you find one that suits your workflow.
Step 8: Build Your Own Custom Theme (Optional)
Create and place your theme file at:
~/.oh-my-zsh/themes/mycustomtheme.zsh-theme
Use below minimal custom theme to start
# ~/.oh-my-zsh/themes/mycustomtheme.zsh-theme
# Prompt: username@host (green) + last 2 dirs (blue) + prompt char + git status
PROMPT="%{$fg_bold[green]%}%n@%m%{$reset_color%} \
%{$fg_bold[blue]%}%2~%{$reset_color%} \
%{$fg_bold[white]%}%#%{$reset_color%} "
# Display git branch
PROMPT+='$(git_prompt_info)'
# Git prompt formatting
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})%{$reset_color%}"
Enable the theme
# Update theme
ZSH_THEME="mycustomtheme"
# Reload the config
source ~/.zshrc
Oh-My-Zsh directory structure
Knowing the folder layout helps you manage plugins, themes, and customizations properly.
graph LR
A[~/.oh-my-zsh] --> B[themes/]
A --> C[plugins/]
A --> D[lib/]
A --> E[custom/]
E --> F[custom themes]
E --> G[custom plugins]
A --> H[oh-my-zsh.sh]
Troubleshooting
Terminal still opens in Bash ?
Add this to ~/.bashrc, it forces interactive Bash sessions to switch into Zsh.
if [ -t 1 ] && [ "$SHELL" != "/bin/zsh" ]; then
exec zsh
fi
Uninstalling Oh-My-Zsh safely
Step 1: Restore Bash history
Zsh adds metadata timestamps.
Clean them before merging back into Bash history.
# Backup bash history
cp ~/.bash_history ~/.bash_history_backup
# clean and update bash history
sed 's/^: [0-9]*:[0-9]*;//' ~/.zsh_history >> ~/.bash_history
# sort the history
sort -u ~/.bash_history -o ~/.bash_history
Step 2: Remove auto-switch script
Edit ~/.bashrc and remove or comment this block.
if [ -t 1 ] && [ "$SHELL" != "/bin/zsh" ]; then
exec zsh
fi
Step 3: Switch back to Bash & remove Zsh
# Set default shell to Bash
chsh -s /bin/bash
# load history
history -r ~/.bash_history
# remove Zsh
sudo apt remove --purge zsh
sudo apt autoremove
Summary
This article provides a complete workflow of: setup → enhance → customize → maintain.
Your Linux terminal is now:
- Faster
- More customizable
- More productive
- Much easier to use
You learned how to:
- Install Zsh
- Install Oh My Zsh
- Enable plugins
- Apply and create themes
- Sync Bash history
- Fix shell startup issues
- Uninstall cleanly
