Setup terminal with ZSH on windows

Below diagram explains what we are going to do.

hyper terminal with zsh on windows

So to list the steps, we'll

  • Install WSL (Windows subsystem for linux)
  • Install Ubuntu from Microsoft store
  • Install zsh shell
  • Install oh my zsh
  • Install PowerLevel10k
  • Plugins
  • Choose a terminal
  • Colors
  • Points worth noting



YouTube logo
Watch the video instead 👉 YouTube Link, covers each step.




Installations

WSL

I just enabled 'Windows Subsystem for Linux' in Windows Feature and restarted the system.

enable windows subsystem for linux

You can follow the instructions on Microsoft website.


Ubuntu

For this, visit this Microsoft Store webpage and install it.

Download size 444.5MB on 05-12-2020

After it is installed. Open it from start menu to continue installation.
Setup will ask for a username for linux subsystem.

WSL Setup

After entering username, the setup will finish.

WSL Setup

Update the packages with following command

sudo apt update && sudo apt upgrade

ZSH

Install ZSH with following command

sudo apt-get install zsh

Make zsh the default shell with following command:

 chsh -s /usr/bin/zsh 

Restart the Ubuntu app and you should be greeted with following screen:

zsh welcome screen

Complete the configuration as per your liking.


OH MY ZSH

Next, lets install 'OH MY ZSH' with following command:

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Below is the screenshot of completed installation.

Oh my zsh


PowerLevel10k

Time to spice up the terminal with a nice theme.

But before that, Install the recommended font 'Meslo Nerd Font':

Why?
Icons will render properly with this font

You can download the fonts from this GitHub page.

To install a font, open it and click install button on top

Install PowerLevel10k

Now, for PowerLevel10k, you can follow the guide at https://github.com/romkatv/powerlevel10k

Below are the steps I've taken:

  1. Installation of PowerLevel10k for Oh My Zsh

    git clone --depth=1 https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k
    
  2. Set ZSH_THEME="powerlevel10k/powerlevel10k" in ~/.zshrc.
  3. Restart the Ubuntu app.
  4. You will be prompted with the configuration wizard for PowerLevel10k. If not, type p10k configure if the configuration wizard doesn't start automatically.

PowerLevel10k Config

After doing the configuration, my terminal looked like below:

PowerLevel10k Config Done


Plugins

zsh-autosuggestions

This plugin will suggest command as you write from the terminal history.
Just use right arrow key to complete the command.

Link: https://github.com/zsh-users/zsh-autosuggestions

Steps I followed:

  1. Installation

    git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
    
  2. To activate the autosuggestions, add it to plugin list in your .zshrc:
    ZSH Plugins
  3. You will also need to force reload of your .zshrc:

    source ~/.zshrc
    

    Try typing any command if its available in the history, you will see suggestion as below and then you press -> right arrow key to complete it.
    ZSH AutoSuggestion plugin


Choose a terminal

So far we have just configured a shell, zsh in this case.

Time to pick a terminal of choice.

Terminals are dumb. They are just UI layer. They take input and pass it on (to a shell for example). You can choose any terminal like Hyper, cmder, Windows Terminal etc etc.

Up till now, we have been using the Ubuntu app as our terminal. You can continue using that and it works fine.

In case you want to switch, below i have notes on few of them.

All terminals

Windows Terminal

Install

Install it from Microsoft Store

Font

Open its settings from the dropdown and add fontFace to the profile named Ubuntu as shown below

Windows Terminal Profile

Default Profile

By default it opens up PowerShell. You can change it by assigning the GUID of Ubuntu profile to the defaultProfile in the settings.


Hyper

Install

Font

Make hyper use the custom font we installed earlier.
Open Hyper Terminal config file with ctrl+, and add 'MesloLGS NF,' in front of the existing value for fontFamily key.

Shell

Lets tie hyper with Window's bash now.

  • Open Hyper's configuration file with ctrl+,.
  • Scroll down and edit shell's value to C:\\Windows\\System32\\bash.exe.
  • Configuration we did in last step, will always open bash shell in Hyper.
    To switch to ZSH on startup, Open your bash profile with

    vim ~/.bashrc
    

    Add following in the very beginning of the file

    zsh
    
  • Save and relaunch Hyper.

Hyper Theme

Colors

The colors were a little bit bright for me. So I installed a theme for hyper terminal named 'hyper-material-theme' from Hyper Website using below command:

⚠ Make sure you are running the hyper command from windows terminal. Meaning you are out zsh or linux terminal per se.
Use exit command to get out of zsh.

hyper i hyper-material-theme

Now colors are nice!

Hyper Theme

Issue

One issue I noticed with hyper terminal is that it doesn't refresh/clear the screen after nano editor is closed.

As shown below, Hyper(on left) and Windows Terminal(on right) after closing nano editor.

Hyper render issue


Cmder

Install

Font

Make Cmder use the custom font we installed earlier.
Open settings and select 'MesloLGS NF' as shown below

Cmder font

Shell

Lets tie cmder with Window's bash now.

Add a new task in cmder's settings window as shown below

Cmder font

  • Save and relaunch Cmder.

Points worth noting:


Thats it for this note.
HIH ~ RD

Helpful?

If you think this is helpful 🎈
Don't keep it to yourself 🙊

Share it with your lovely followers at twitter 🗽

lets connect viatwitter