Script Valley
Developer Environment Setup (WSL, Terminal, VS Code)
Shell Configuration and ProductivityLesson 3.3

How to install and use Zsh with Oh My Zsh on WSL2

installing zsh, chsh to change default shell, Oh My Zsh installation, themes, plugins array, zsh-autosuggestions, zsh-syntax-highlighting, .zshrc config file

Zsh and Oh My Zsh

Oh My Zsh layer diagram

Zsh is an extended version of Bash with better tab completion, globbing, and plugin support. Oh My Zsh is a community framework that manages Zsh plugins and themes with one config file.

Install Zsh

sudo apt install zsh -y
zsh --version

Install Oh My Zsh

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

The installer asks to make Zsh your default shell. Choose yes, or set it manually with chsh -s $(which zsh).

Configuring plugins in ~/.zshrc

plugins=(git node npm z zsh-autosuggestions zsh-syntax-highlighting)

Installing zsh-autosuggestions (not bundled)

git clone https://github.com/zsh-users/zsh-autosuggestions \
  ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

Changing the theme

ZSH_THEME="agnoster"
source ~/.zshrc

After installing, open a new terminal to confirm Zsh is active: the prompt style will have changed and typing partial commands will show grey autosuggestions.

Up next

How to use tmux to manage multiple terminal sessions

Sign in to track progress