Supercharge Your Terminal ZSH
Zsh is a powerful shell that can completely transform your terminal experience with better customization, plugins, and themes. In this guide, we’ll set up Zsh with Oh My Zsh, install useful plugins, and configure a sleek prompt.
First, make sure your system is up to date and install zsh:
sudo apt-get update
sudo apt install zsh -y
Change the default shell to Zsh and log out and back in:
chsh -s $(which zsh)
When prompted, choose option 0
for your user. After logging back in, you’ll be running Zsh.
Before moving forward, let’s ensure some basic tools are installed:
sudo apt-get install git curl vim -y
Run the official installer script to set up Oh My Zsh:
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
This will set up the framework that makes plugin and theme management super easy.
We’ll add two popular Zsh plugins:
- zsh-syntax-highlighting → Colorizes commands as you type
- zsh-autosuggestions → Suggests commands from your history
Clone them into your ~/.oh-my-zsh/custom/plugins
folder:
git clone [email protected]:zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting
git clone [email protected]:zsh-users/zsh-autosuggestions.git ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
.zshrc
file and configure it like this:
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
# Choose a theme (try "avit" or "agnoster")
ZSH_THEME="avit"
# Enable plugins
plugins=(
git
zsh-syntax-highlighting
zsh-autosuggestions
history
dirhistory
colored-man-pages
jsontools
)
# Custom prompt tweaks
prompt_dir(){
prompt_segment blue $CURRENT_FG '%1~'
}
prompt_end() {
if [[ -n $CURRENT_BG ]]; then
print -n "%{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR"
else
print -n "%{%k%}"
fi
print -n "%{%f%}"
CURRENT_BG=''
# Adds the new line and ➜ as the start character.
printf "\n ➜";
}
# Show timestamps in history
HIST_STAMPS="yyyy-mm-dd"
# Load Oh My Zsh
source $ZSH/oh-my-zsh.sh
Apply changes by reloading your shell:
source ~/.zshrc