Style your Windows terminal and use WSL and PowerShell like a pro
Tags: windowsterminal, zsh, wsl, ohmyzsh
Published: 2020-02-15 18:22:48

---
title: Style your Windows terminal and use WSL and PowerShell like a pro
published: true
date: 2019-11-14 11:12:11 UTC
tags: windowsterminal,zsh,wsl,ohmyzsh
canonical_url: https://medium.com/@hjgraca/style-your-windows-terminal-and-wsl2-like-a-pro-9a2e1ad4c9d0
---

With zsh and powerline10k you can have a terminal that will make your unix friends jealous 😀

![](https://cdn-images-1.medium.com/max/1024/1*3zKJWYBLG3G9IJsonITdpg.png)<figcaption>Finished look of the terminal</figcaption>

### Some assumptions

- Have **WSL** installed. If not you can follow the [**official docs**](https://docs.microsoft.com/en-us/windows/wsl/install-win10) (I am using Ubuntu 18.04). Once you finished installing you need to setup for the first time, follow tutorial [here](https://docs.microsoft.com/en-us/windows/wsl/initialize-distro)
- (optional) Have **WSL 2** installed following the [**official docs**](https://docs.microsoft.com/en-us/windows/wsl/wsl2-install) **(**WSL 2 is only available in Windows 10 builds 18917 or higher)
- Have the new **Windows Terminal** (preview) installed. You can get it from the [**Windows Store**](https://www.microsoft.com/en-us/p/windows-terminal-preview/9n0dx20hk701)

### Getting Started

Without any styling you should have something very similar to this

![](https://cdn-images-1.medium.com/max/1024/1*jQr-2NhKrP0KxLm_noAUfg.png)<figcaption>Default Windows Terminal screen</figcaption>

The first thing I recommend it to go into the settings and change the default profile to Ubuntu. After you click settings your json editor will popup with the profiles.json file.

![](https://cdn-images-1.medium.com/max/1024/1*quihVzthNVVRvsIjkQbMJg.png)

Next you are going to add two new schemes to the file and change the default values from the PowerShell and Ubuntu profiles. The end result will be:

{% gist https://gist.github.com/hjgraca/e417313ca055d3a210edd7c113a23841 %}

Great after we saved the file we should see something different

![](https://cdn-images-1.medium.com/max/1024/1*ROBh9exlXIhDZOKJUJf-ag.png)<figcaption>Ubuntu</figcaption>

![](https://cdn-images-1.medium.com/max/1024/1*6d1TZiH5cpyxYRfq_wEReQ.png)<figcaption>PowerShell</figcaption>

Looks better but not there yet. You must have noticed the font faces in the profiles, those do not exist in windows by default so we need to install them.

### Fonts

**Install Powerline fonts in Windows**  
To have a correctly working theme, you needed to download and install some needed fonts.

Open Powershell command prompt:

```
git clone [https://github.com/powerline/fonts.git](https://github.com/powerline/fonts.git) --depth=1

cd fonts

.\install.ps1

# this will take a while to install all fonts. you can delete the folder after.
```

Next go to [**Nerd Fonts**](https://www.nerdfonts.com/) and download and install the font you like. In this tutorial I downloaded the [**mononoki**](https://github.com/ryanoasis/nerd-fonts/releases/download/v2.0.0/Mononoki.zip)font. These are custom fonts and icons for your terminal.

![](https://cdn-images-1.medium.com/max/1024/1*8nx5Eoaexv-CRNngxGQxPA.png)<figcaption><strong>Unzip the file</strong></figcaption>

![](https://cdn-images-1.medium.com/max/1024/1*qdpZgR2BPT4i_yDByBJ8rA.png)<figcaption><strong>And install the font</strong></figcaption>

### PowerShell

Let´s start by styling PowerShell (scroll down if you want to see WSL). You will need to have [**installed Git for Windows**](https://git-scm.com/downloads) **.**

Follow [**these directions**](https://github.com/JanDeDobbeleer/oh-my-posh?WT.mc_id=-blog-scottha#installation), this will install Posh-Git and Oh-My-Posh.

Install posh-git and oh-my-posh:

```
# You could have the following to allow for scripts execution 
# Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser
```

Enable the prompt:

```
# Start the default settings (might not work so optional)
Set-Prompt

# To enable the engine edit your PowerShell profile, run
notepad $PROFILE

# and append the following lines to the profile file you just opened (or created in case the file was not there already):

Import-Module posh-git
Import-Module oh-my-posh
Set-Theme Paradox
```

Once you are done this is what your PowerShell will look like. You can get other themes [here](https://github.com/JanDeDobbeleer/oh-my-posh?WT.mc_id=-blog-scottha#themes). And as you can see all icons are there including the git icons 😎

![](https://cdn-images-1.medium.com/max/1024/1*owAPKY34QVh51dcD7Xt1Aw.png)

### WSL

Now that we have PowerShell styled lets take care of Ubuntu.

1. First install zsh

```
sudo apt-get install zsh curl git
```

2. Install [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh).

```
# When prompted to set zsh as your default shell say Yes

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

If all went well, your Ubuntu terminal shell should look like this. Just your username in the prompt.

![](https://cdn-images-1.medium.com/max/1024/1*xjbxiWHptMBu9nA8dNk7pA.png)

Now we are ready to add some themes. I will be using [**Powerlevel10k**](https://github.com/romkatv/powerlevel10k) **.** And because we have **oh my zsh** installed we just need to run the following scripts

```
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git $ZSH\_CUSTOM/themes/powerlevel10k
```

Set ZSH\_THEME=powerlevel10k/powerlevel10k in your ~/.zshrc. To do that run vim ~/.zshrcand replace the **ZSH\_THEME** value. Save and exit Vim 😂

![](https://cdn-images-1.medium.com/max/1024/1*QU3CuE6A40f0dUWbAcHMdw.png)

Now restart the Windows Terminal and you should see the Powerlevel10k configuration wizard

![](https://cdn-images-1.medium.com/max/1024/1*m6DMoVhPLZzHVuJZ9tEqJw.png)

If all the fonts were installed correctly you should see a diamond (like above) a lock and a debian logo. Follow the wizard until the end and then apply your changes to the ~/.zshrc file

Depending on the style you chose you should have a good looking terminal like this.

![](https://cdn-images-1.medium.com/max/1024/1*V826s1-NRtU6dfhwz1tQYg.png)

That’s it you now have a very good looking PowerShell and WSL terminal that will make your unix friends jealous 😍

### Extras for WSL

**Plugins**

zsh and Powerlevel10k have an enormous amount of plugins and extensions that you can add to your shell.

**Add Auto Suggestions (**[**repo**](https://github.com/zsh-users/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](https://github.com/zsh-users/zsh-autosuggestions) ${ZSH\_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
```

2. Add the plugin to the list of plugins for Oh My Zsh to load (inside ~/.zshrc): (you will probably have git already)

```
plugins=(zsh-autosuggestions)

# and bellow add: to fix the suggestion style

ZSH\_AUTOSUGGEST\_HIGHLIGHT\_STYLE="fg=244"
```

3. Start a new terminal session. And now you have auto suggestions.

**Kubectl plugin (**[**repo**](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/kubectl)**)**

For those like me that have to deal with Kubernetes this is an amazing plugin, because it gives you autocomplete and many aliases for you to have to type less. What do you have to do?! Very easy just open ~/.zshrc and edit the plugins line and add kubectl. Save and exit Vim

```
plugins=(git zsh-autosuggestions **kubectl** )
```

Restart the terminal session

**Styling the prompt with Powerlevel10k**

We can add many things to the prompt, like aws or azure login user information, Kubernetes cluster and namespace information, nodejs version and so on. To do so we need to edit the Powerlevel10k configuration file **~/.p10k.zsh** :

```
vim ~/.p10k.zsh
```

Change the POWERLEVEL9K\_LEFT\_PROMPT\_ELEMENTS to change the left hand side of the prompt.

![](https://cdn-images-1.medium.com/max/1024/1*fv0O_ieJfia8IKZBfUh0kw.png)

Change the POWERLEVEL9K\_RIGHT\_PROMPT\_ELEMENTS to change the right hand side of the prompt. This is where most of the elements are.

![](https://cdn-images-1.medium.com/max/1024/1*Gvefes9EzZWiTlfFw60WZQ.png)

For example to add the Kubernetes cluster and namespace information I just enable the **kubecontext** element. And for the battery information the **battery ** element

![](https://cdn-images-1.medium.com/max/1024/1*yWP-hVtYoY4nJFkyITW0kg.png)<figcaption>In pink the Kubernetes cluster(aks9533) and namepsace (demo).</figcaption>

And that’s it, totally customizable and good looking terminal. To learn more have a look at the [style your prompt guide](https://github.com/Powerlevel9k/powerlevel9k/wiki/Stylizing-Your-Prompt) of Powerlevel9k (original project) to know what to change.