Published on

Set up Wsl with zsh and oh-my-zsh

2 min read
Table of Contents

In this post we will see how can we install and setup up zsh shell and use oh-my-posh with it in wsl ubuntu.

Setup Z Shell

Install the Z shell and git

sudo apt install zsh
sudo apt install git

Check the Z shell version

zsh --version

Change the default shell

chsh -s $(which zsh)

Log out and login again to use the new default shell

Check the current shell

echo $SHELL // Expected result: /bin/zsh

Install Oh My Zsh

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

Install zsh-autosuggestions and zsh-syntax-highlighting

Set up zsh-syntax-highlighting

  1. Clone this repository into $ZSH_CUSTOM/plugins (by default ~/.oh-my-zsh/custom/plugins):
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

Set up zsh-autosuggestions

  1. Clone this repository into $ZSH_CUSTOM/plugins (by default ~/.oh-my-zsh/custom/plugins)
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

Plugins

Oh My Zsh comes with a shitload of plugins for you to take advantage of. You can take a look in the plugins directory and/or the wiki to see what's currently available.

Enabling Plugins

Once you spot a plugin (or several) that you'd like to use with Oh My Zsh, you'll need to enable them in the .zshrc file. You'll find the zshrc file in your $HOME directory. Open it with your favorite text editor and you'll see a spot to list all the plugins you want to load.

vi ~/.zshrc

For example, this might begin to look like this:

plugins=(
  git
  zsh-autosuggestions
  zsh-syntax-highlighting
)

Load the config

source ~/.zshrc