ZSH and Oh-My-Zsh on Windows Subsystem for Linux (WSL)

ZSH and Oh-My-Zsh on Windows Subsystem for Linux (WSL)

In this posting, I will show how to install ZSH and Oh-My-Zsh on Windows PC (WSL). This will be helpful if you want to setup a Linux development environment on Windows PC.

I have already installed Ubuntu 20.04 on Windows Subsystem for Linux (WSL). Bash is the default shell program. With using a different shell program, ZSH, we can access many features that Bash does not provide. It offers aesthetically pleasant themes and powerful plugins that can boost your productivity. Oh-My-Zsh makes it easier for us to handle ZSH configurations.

You can follow the steps in this video.

Install ZSH

sudo apt-get install zsh

After installation, you will find .zshrc file inside your home directory. We will come back to that file for configuration later on.

2. Install Oh-My-Zsh

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

Oh-My-Zsh includes many themes and plugins. You will find .oh-my-zsh directory inside your home directory. For curiosity, you can navigate pre-shipped themes and plugins. If you add a custom or external theme or plugin, they should store inside the custom directory. The next step is one good example. We will install an external theme, Powerlevel10K, which is very popular now among developers.

Before doing this, let's restart your terminal.

3. Install a few required fonts for Powerlevel10K theme.

Go to https://github.com/romkatv/powerlevel10k#meslo-nerd-font-patched-for-powerlevel10k. Download and install four MesloLGS NF fonts to your PC (double-clicking the downloaded ttf file for installation).

4. Install Powerlevel10K

git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

You can find the theme installed in ~/.oh-my-zsh/custom/themes.

5. Update the theme name inside .zshrc file.

Open the file .zshrc at your home directory. Find the line of ZSH_THEME and replace with the new theme.

ZSH_THEME="powerlevel10k/powerlevel10k"

Restart your terminal.

6. Configure ZSH theme (powerlevel10k) with Oh-My-Zsh

When you restart your terminal, you will find interactive windows that lead you through many powerlevel10k theme options. Select as you like. We are all done. You can now enjoy the beautiful theme.

7. Bonus! Install two plugins

Install zsh-syntax-highlighting

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting

Install zsh-autosuggestions

git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions

After installation, open the file .zshrc and find the line plugins=(git). Update it with plugins=(git zsh-autosuggestions zsh-syntax-highlighting)

8. Change the font in Visual Studio Code terminal

Open Settings and search "terminal.integrated.fontFamily." And add the font name, MesloLGS NF. This will make you use powerlevel10k theme inside VSC terminal.