Spice up linux based terminal in Windows
Tags: windows, terminal, ohmyzsh, theme
Published: 2021-10-14 19:41:58

I am a fan of Windows UI and Linux terminal interface at the same time. Yes! we do exist 😉. During my college days, I set up dual boot in my laptop - both Windows and Linux. It allowed me to finish assignments, for which I preferred the Linux terminal. At the same time, I could play CSGO 🔫 in Windows by switching the OS. However, with the office-provided laptop, I could only use Windows 😞. I was missing the Linux terminal, and the Windows native terminal sucked as I was habitual of using Linux commands that usually don't work.

I got introduced to Windows Subsystem for Linux (WSL) a few days back, which empowered me to run Linux commands in windows. On top of it, I configured the terminal to look extravagant as below (notice those colored instructions and icons):
![Spicy Terminal](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tivphnvb85hu1lxnqdzu.png)  

In this blog, I will be sharing steps, by following which you can also set up a terminal similar to this and enjoy Linux terminal features natively in Windows. 

Let's get started.

## 1. Installing WSL in Windows.

**Step 1**: Enable WSL feature.

To run WSL on windows, you first need to enable the feature.
Go to **Settings** > **Apps** > **App** & **Features**. Under **Related Settings** section select **Program and Features**.
![Program and Features](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/my3iajzf2811kstvuvue.png)

Now select **Turn Windows features on or off** option on left. From the list of open options, turn **Windows subsystem for Linux** on.
![Windows subsystem for Linux](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bik3vaf16w3nr6tokp6f.png)

**Step 2**: Install Linux distribution
 
Go to **Microsoft** store and search for **Linux distros**. You will see many options like Ubuntu 20.94LTS, Kali Linux, Ubuntu 18.04LTS, Debian, SUSE Linux. You can download any one of them as per your preference. I prefer using Ubuntu as I have already used it.
![Linux distros on Microsoft store](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uz93xgrg3s7qmjo8oxbx.png)

Once installed, launch the downloaded Linux distros by searching from the Start menu or from the Microsoft store itself. For the first time, you will be asked to set your username and password.

After you complete the above steps, you are ready to use the Linux terminal in Windows. Try playing around with the commands. Pretty cool 😎, right. Now let's move on to give this terminal a makeover to make it look attractive.
 
## 2. Giving terminal a fresh look

**Step 1:** Install `zsh`

`zsh` is a type of shell similar to `bash` but more interactive. (Learn more about zsh [here](https://www.zsh.org/)). Run the following command to install zsh:

```
sudo apt-get install zsh
```

After installation is complete, make sure it's installed by running `zsh --version`. If it shows a version, be assured that zsh is installed.

**Step 2:** Install `oh-my-zsh`

[oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh#readme) is a powerful plugin manager for `zsh` shell. It includes **[300+](https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins)** optional plugins (rails, git, OSX, hub, docker, homebrew, node, php, python, etc...), **140+** themes to spice up your morning, and an auto-update tool, so that makes it easy to keep up with the latest updates from the community.

Quoting from oh-my-zsh:

> Once installed, your terminal shell will become the talk of the town or your money back! With each keystroke in your command prompt, you'll take advantage of the hundreds of powerful plugins and beautiful themes. Strangers will come up to you in cafés and ask you, "that is amazing! are you some sort of genius?"

Okay, enough talking about it. Let's see it in action. 🎬

```
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
```
The above command will install `oh-my-zsh` in your terminal and update the `~/.zshrc` file. If you are not aware, `.*rc` files are configuration files. In bash, there is `~/.bashrc`. Similarly, for `zsh` there is `~/.zshrc` file. Every configuration related to the zsh shell will be made here. 

Now you might be wondering what we got out of it. As said earlier, oh-my-zsh will allow you to install various plugins and themes for your terminal. Plugins are there to make your life easier. They make you feel like a 10x developer by powering you with their special abilities. For example, a `git` plugin will show you which branch you are on and how many files are changed on the command line itself—no need to manually run git commands to look for branch or changed files. You can find the list of available plugins [here](https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins). Themes, on the other hand, are to make your terminal look prettier. You can select from a list of available themes([internal-themes](https://github.com/ohmyzsh/ohmyzsh/wiki/Themes), [external-themes](https://github.com/ohmyzsh/ohmyzsh/wiki/External-themes)) as per your preference.

Now you will ask where to add plugins and configure theme? Here comes the role of `~/.zshrc`. Open file in the inline editor with `vi ~/.zshrc`. (Please don't say you don't like vi editor 🙉). Look for the `plugins` variable. There will be default some plugins mentioned already something like below:

```
plugins=(
  git
  bundler
  dotenv
  osx
  rake
  rbenv
  ruby
)
```

You can either add or delete a plugin as per your need. You can search for the plugins from the list shared above.

Now coming to the theme, you will see a variable `ZSH_THEME` and a default theme mentioned `ZSH_THEME="robbyrussell"`.

I don't like the default theme and prefer `powerlevel10k` theme instead. It's swift and lightweight and works like a charm. So in the following steps, I will be sharing how to set up the `powerlevel10k` theme. If you like to install another theme, it's okay; you can use it from the list of available themes. (Shared link above).

**Step 3:** Install powerlevel10k theme.

Run the following command to clone the repo :

```
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
```
After cloning, set `ZSH_THEME="powerlevel10k/powerlevel10k"` in `~/.zshrc`. Now run `source ~/.zshrc`. For first-time users, `powerlevel10k` will ask a set of questions to configure your terminal look. If it does not ask, don't worry; run `p10k configure` in the terminal.

If you notice that icons or shapes are not rendering properly, it means required font is not installed. Install all the fonts mentioned [here](https://github.com/romkatv/powerlevel10k#manual-font-installation).

Once you have installed fonts in Windows, open Linux terminal settings (as shown below):
![Terminal settings](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rfupu23yplda0mt5io35.png)
 
From the settings panel, set font as **MesloLGS NF Regular**.
![Set up font](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u3y128bo7pgv22frvg5w.png).

After setting up the font, run `p10k configure` to reconfigure the theme, and now you will be able to see all icons and shapes.

Did it spice up your experience of Linux terminal in Windows ?
 
I hope this is helpful and interesting to you. If you find this useful, please leave a like and comment down your thoughts.

I am on [Twitter](https://twitter.com/utkarsh22garg). You can follow me there.

**Cover Credit**: Photo by <a href="https://unsplash.com/@6heinz3r?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Gabriel Heinzer</a> on <a href="https://unsplash.com/s/photos/linux?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>