Terminal Setup: Zsh, Oh My Zsh and Powerlevel10k Guide
In this tutorial, you'll learn to set up a powerful terminal environment with Zsh, Oh My Zsh, Powerlevel10k theme, and essential plugins that transform your command-line experience from basic to world-class.
Why a Terminal Setup Matters
The terminal is where developers spend most of their time. A well-configured terminal saves seconds on every command, minutes per hour, and hours per week. Features like syntax highlighting, autosuggestions, and a useful prompt reduce cognitive load and prevent errors.
By the end of this guide, you'll have a fully customized terminal with intelligent prompts, plugin-based productivity boosts, and a configuration you can replicate across machines.
What is Zsh?
Zsh (Z Shell) is a Unix shell designed for interactive use. It is an extended version of Bourne Shell (sh) with powerful improvements over Bash, the default shell on most Linux and macOS systems.
flowchart LR A[Bash] --> B[Zsh] B --> C[Oh My Zsh] C --> D[Powerlevel10k] C --> E[Plugins] D --> F[Beautiful Prompt] E --> G[Autosuggestions] E --> H[Syntax Highlighting] E --> I[Completions]
Key Zsh Features
| Feature | Benefit |
|---|---|
| Auto-completion | Smarter tab completion with menu navigation |
| Glob operators | Advanced file matching (**/*.txt) |
| Spelling correction | Auto-corrects mistyped commands |
| Themeable prompts | Fully customizable prompt appearance |
| Shared history | History across running sessions |
Installing Zsh
On macOS
macOS switched to Zsh as the default shell in Catalina (10.15). Verify with:
echo $SHELL
If it doesn't show /bin/zsh, install via Homebrew:
brew install zsh
On Linux (Ubuntu/Debian)
sudo apt update && sudo apt install zsh -y
chsh -s $(which zsh)
Expected Output
After switching, restart your terminal and verify:
zsh --version
# zsh 5.9 (x86_64-ubuntu-linux-gnu)
Installing Oh My Zsh
Oh My Zsh is a framework that manages Zsh configuration and provides thousands of plugins and themes.
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
The installer backs up your existing .zshrc and creates a new one pre-configured for Oh My Zsh.
Expected Output
Looking for an existing zsh config...
Found ~/.zshrc. Backing up to ~/.zshrc.pre-oh-my-zsh
Using the Oh My Zsh template file and adding it to ~/.zshrc
Powerlevel10k Theme
Powerlevel10k is the fastest and most feature-rich theme for Zsh. It provides a context-aware prompt showing Git status, command execution time, Python virtualenv, and more.
Installation
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git \
${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
Set the theme in ~/.zshrc:
ZSH_THEME="powerlevel10k/powerlevel10k"
The first time you open a new terminal, Powerlevel10k launches its interactive configuration wizard. It asks about prompt style, icons, layout, and more. The settings are saved to ~/.p10k.zsh.
Manual Configuration
You can edit ~/.p10k.zsh directly to change prompt elements:
# Change prompt from lean to classic style
POWERLEVEL9K_MODE=classic
# Add or remove prompt elements
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(os_icon dir vcs)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status time)
Essential Plugins
Oh My Zsh plugins add functionality to your shell. Enable them by editing the plugins array in ~/.zshrc.
plugins=(
git
zsh-autosuggestions
zsh-syntax-highlighting
web-search
docker
docker-compose
npm
node
vscode
)
zsh-autosuggestions
This plugin suggests commands based on history as you type. Press the right arrow key to accept.
git clone https://github.com/zsh-users/zsh-autosuggestions \
${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
zsh-syntax-highlighting
Commands turn green if valid, red if invalid. This prevents running mistyped commands.
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git \
${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
Expected Behavior
When you type git status, the text appears in green. When you type gti status, it appears in red, warning you before execution.
Aliases and Functions
Oh My Zsh bundles many useful aliases. Here are the most impactful for Git:
# ~/.zshrc aliases
alias gs='git status'
alias ga='git add'
alias gc='git commit'
alias gp='git push'
alias gl='git log --oneline --graph --decorate --all'
alias gco='git checkout'
alias gb='git branch'
Add your own:
alias cat='bat' # Syntax-highlighted cat replacement
alias ls='eza --icons' # Better ls with icons
alias ll='eza -la --icons' # Detailed listing
alias tmux='tmux -2' # Force 256 color mode
alias weather='curl wttr.in' # Weather in terminal
Prompt Customization
Powerlevel10k prompts are deeply customizable. Common customizations include:
# Show time in prompt
POWERLEVEL9K_TIME_FORMAT='%D{%H:%M:%S}'
# Show command execution time if > 3 seconds
POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=3
# Show Python virtualenv
POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV=true
File Structure
Your configuration files after setup:
~/
├── .zshrc # Main Zsh config
├── .zshrc.pre-oh-my-zsh # Backup of original config
├── .p10k.zsh # Powerlevel10k theme config
├── .zsh_history # Command history database
└── .oh-my-zsh/
├── custom/
│ ├── themes/
│ │ └── powerlevel10k/
│ └── plugins/
│ ├── zsh-autosuggestions/
│ └── zsh-syntax-highlighting/
├── themes/
├── plugins/
└── lib/
Updating and Maintenance
Update Oh My Zsh components:
# Update Oh My Zsh
omz update
# Update Powerlevel10k
git -C ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/powerlevel10k pull
# Update plugins
git -C ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions pull
git -C ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting pull
Common Errors
| Problem | Cause | Fix |
|---|---|---|
| Prompt shows weird characters | Missing Nerd Font or Powerline font | Install a Nerd Font and set it in terminal preferences |
| Plugins not loading | Wrong plugin path in ~/.zshrc |
Verify paths under $ZSH_CUSTOM/plugins/ |
| zsh-syntax-highlighting breaks completion | Load order issue | Ensure syntax-highlighting is last in plugins array |
| Powerlevel10k prompt shows "no such theme" | Wrong theme name | Set ZSH_THEME="powerlevel10k/powerlevel10k" |
| Slow prompt in large Git repos | Git status check is expensive | Add POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN="~/big-repo" |
Practice Questions
1. What command switches your default shell to Zsh?
chsh -s $(which zsh)
2. How do you update Oh My Zsh from the command line?
Run omz update.
3. What file stores your Powerlevel10k configuration after the wizard?
~/.p10k.zsh
4. Why should zsh-syntax-highlighting be the last plugin in the plugins array?
It hooks into the completion system and can break completions if other plugins load after it.
5. What is the purpose of the $ZSH_CUSTOM variable?
It points to ~/.oh-my-zsh/custom/, the directory where user-installed themes and plugins are stored.
Challenge
Create a custom Zsh plugin that defines a function called mkcd which creates a directory and changes into it in one step. Register it as a plugin in Oh My Zsh and test it.
Real-World Task
Set up your development terminal environment on a fresh machine with Zsh, Oh My Zsh, Powerlevel10k, and the autosuggestions and syntax-highlighting plugins. Configure aliases for Git, Docker, and Node.js workflows. Take a screenshot of the final prompt showing a Git Repository status, a Python virtualenv indicator, and command execution time.
Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro