Introduction
Zsh is a powerful and customizable shell that can greatly enhance your command-line experience. Paired with “Oh My Zsh,” a framework for managing Zsh configurations, it provides features like theme support, plugin management, and much more. This article explains how to set up Zsh and Oh My Zsh on Debian.
Installing Zsh
Before setting up “Oh My Zsh,” you need to install Zsh on your Debian system.
sudo apt update
sudo apt install zsh -y
To verify the installation, run:
zsh --version
Setting Zsh as Default Shell
Switch your default shell to Zsh:
chsh -s $(which zsh)
Log out and back in to apply the changes.
Installing Oh My Zsh
Oh My Zsh is a popular framework that simplifies Zsh customization. Install it using the following command:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Choosing a Theme
Oh My Zsh includes a variety of themes. The default theme is robbyrussell
, but you can change it by editing your .zshrc
file:
vim ~/.zshrc
Locate the line:
ZSH_THEME="robbyrussell"
I chose Powerlevel10k:
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/powerlevel10k
Change the theme:
ZSH_THEME="powerlevel10k/powerlevel10k"
Installing Powerline Fonts
Some themes require Powerline fonts for proper rendering. Install them using:
sudo apt install fonts-powerline
After installation, change your terminal font to a Powerline-compatible font through your terminal emulator’s settings.
Adding Plugins
Oh My Zsh supports plugins that enhance your workflow. Popular plugins include git
, zsh-autosuggestions
, and zsh-syntax-highlighting
.
Enable Default Plugins
Edit your .zshrc
file and locate the plugins
line:
plugins=(git)
Add additional plugins as needed:
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
Install Additional Plugins
For plugins not included by default, you need to clone them into the Oh My Zsh plugins directory.
Zsh Autosuggestions
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
Zsh Syntax Highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
Reload Zsh to apply changes:
source ~/.zshrc
Customizing the Prompt
You can fully customize your prompt by modifying the PROMPT
variable in your .zshrc
. For example, to show the username, hostname, and current directory:
PROMPT='%n@%m:%~ %# '
Reload Zsh after making changes:
source ~/.zshrc