Customize & Beautify your Windows Terminal (2022 Edition)
Tags: windows, terminal, powershell, tutorial
Published: 2022-01-28 09:47:37

Windows Terminal is a modern terminal application for developers who frequently uses command-line tools such as Powershell. In this article, I’ll show you how to customize the **hell** out of Windows Terminal and Powershell so that you can flex on your friends and colleagues 😎.

Here's our final result 👇

![final result](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/usqq255cl7k5e2c4tsq4.png)

Before we begin, please download [Windows Terminal from the Microsoft Store](https://www.microsoft.com/en-us/p/windows-terminal/9n0dx20hk701).

**Table of Contents:**
 - [Windows Terminal Settings](#windows-terminal-settings)
 - [Oh My Posh](#oh-my-posh)
 - [Winfetch](#winfetch)

<hr>

## Windows Terminal Settings

You can open settings via the <kbd>Ctrl</kbd>+<kbd>,</kbd> shortcut or the dropdown menu:

![settings](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8trs9ztsrpfcet15qfyp.png)

### Color Scheme

My color scheme is a slightly modified version of [Sonokai Shusia](https://github.com/g-e-o-m-e-t-r-i-c/sonokai-windows-terminal/blob/main/sonokai-shusia.json). To install the color scheme:

1. Open Settings in Windows Terminal and press the “Open JSON file” button at the bottom left corner. It will open `settings.json` in Notepad.
2. In `settings.json`, scroll down to find the `"schemes"` field, which accepts an array of color scheme objects. Next, paste in my color scheme object before the first object in the array (note that object order does not matter).
    ```json
    {
       ...
       "schemes":
       [
           {
               "name": "Sonokai Shusia",
               "background": "#2D2A2E",
               "black": "#1A181A",
               "blue": "#1080D0",
               "brightBlack": "#707070",
               "brightBlue": "#22D5FF",
               "brightCyan": "#7ACCD7",
               "brightGreen": "#A4CD7C",
               "brightPurple": "#AB9DF2",
               "brightRed": "#F882A5",
               "brightWhite": "#E3E1E4",
               "brightYellow": "#E5D37E",
               "cursorColor": "#FFFFFF",
               "cyan": "#3AA5D0",
               "foreground": "#E3E1E4",
               "green": "#7FCD2B",
               "purple": "#7C63F2",
               "red": "#F82F66",
               "selectionBackground": "#FFFFFF",
               "white": "#E3E1E4",
               "yellow": "#E5DE2D"
          },
          ...
      ]
    }
    ```
3. Save your changes and head back to Windows Terminal. Go to Settings → "Windows Powershell" profile → "Appearance" tab → "Color Scheme", and choose the new color scheme. Then, press "Save".

    ![change color scheme](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b0y0mpk1iy92nur23v99.gif)

If you don’t like my custom theme, check out [Windows Terminal Themes](https://windowsterminalthemes.dev/) website. There are 200+ themes to choose from and you get a quick preview of each theme 🌈.

### Nerd Font

[Nerd Fonts](https://github.com/ryanoasis/nerd-fonts) refer to programming fonts that are patched with a high number of glyphs (icons). Using a nerd font in Windows Terminal is **essential** because normal monospace fonts cannot render icons properly:

![nerd font vs monospace](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ewpy9hm519gikb5w967t.png)

It’s likely that the programming font you’re using (eg. Cascadia Code, Fira Code) already has a Nerd Font version. [Check out this link](https://www.nerdfonts.com/font-downloads) to see the full list of patched Nerd Fonts that you can install.

In my setup, I use [Fira Code Nerd Font](https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/FiraCode.zip). The link will download a ZIP file that contains many TrueType font files. It’s OK to only install the files where the name looks something like `Fira Code XXXXX Nerd Font Complete Windows Compatible`.

After installing Nerd Font:
1. **Restart** your Windows Terminal by closing and re-opening it.
2. Go to Settings → “Windows Powershell” profile → “Appearance” tab → “Font face”, and choose your newly installed Nerd Font:
    ![change font face](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/54l3358udi3qvv5e3x8k.gif)

Now, your Terminal should look a bit more pleasing to the eyes:
![custom color scheme and font](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8ufndgip4jhtj6rmfs20.png)

<hr>

## Oh My Posh

[Oh My Posh](https://ohmyposh.dev/) is a prompt theme engine that lets you beautify the prompt string. This engine requires your Terminal to use a **Nerd Font** so make sure that you followed along the previous steps.

### Setup

1. Install “[App Installer](https://www.microsoft.com/store/productId/9NBLGGH4NNS1)” from Microsoft Store to get the `winget` [Windows Package Manager CLI](https://github.com/microsoft/winget-cli).
    - ⚠ Requires Windows 10 1809 (build 17763) or later
    - Check out [Oh My Posh’s documentation](https://ohmyposh.dev/docs/windows#install) for alternative installation options.

2. Restart your Windows Terminal and run `winget` to check if the package manager is correctly installed.

3. In your Windows Terminal, run
    ```powershell
    winget install JanDeDobbeleer.OhMyPosh
    ```

4. Restart your Windows Terminal. Next, try running `oh-my-posh` in Powershell to see if it’s correctly installed.
    ![Default theme](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wjka4t43gjfktv4pzfnv.png)

5. Run the following command to open your Powershell profile.
    ```powershell
    notepad $PROFILE
    ```
    If notepad shows a prompt saying that “Microsoft.Powershell_profile.ps1” is not found and asks if you would like to create the file, press “Yes” to create the file.

6. Inside the file, paste in the following code and save the file. This will load Oh My Posh on start-up with the default theme.
    ```powershell
    oh-my-posh --init --shell pwsh --config ~/AppData/Local/Programs/oh-my-posh/themes/jandedobbeleer.omp.json | Invoke-Expression
    ```

7. Restart your Terminal. Your Powershell should now load Oh My Posh automatically
    ![Default theme on startup](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i8rc4qnbvo431jtrc7u9.png)
 
### Change Theme

Oh My Posh comes with >70 themes included out-of-the-box. Check out the “[Themes](https://ohmyposh.dev/docs/themes)” page documentation for a gallery of preinstalled themes.

All themes are located in `~\AppData\Local\Programs\oh-my-posh\themes` if you used `winget` to install Oh My Posh. If you used an alternative installation method, [visit the documentation](https://ohmyposh.dev/docs/windows#replace-your-existing-prompt) and select your installation method to see where the themes are located.

Suppose you want to use the [powerlevel10k_rainbow](https://ohmyposh.dev/docs/themes#powerlevel10k_rainbow) preinstalled theme:

1. Open Windows Terminal and run `notepad $PROFILE` in Powershell just like we did previously.

2. In the opened file, change the path after `--config` so that it uses `powerlevel10k_rainbow.omp.json`:
    
    ```powershell
    oh-my-posh --init --shell pwsh --config ~/AppData/Local/Programs/oh-my-posh/themes/powerlevel10k_rainbow.omp.json | Invoke-Expression
    ```

3. Restart your Terminal:
    ![powerlevel10k_rainbow theme](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xhj64itze3a2bhgkg86a.png)

### Custom Themes

You can easily create your own theme by writing your own JSON files. Here are some useful links:

- [“Configuration → General” page of the docs](https://ohmyposh.dev/docs/config-overview) - Learn how to create custom themes
- [Nerd Font’s cheatsheet](https://www.nerdfonts.com/cheat-sheet) - List of different glyphs that you can use

I created a custom theme called `p10k_classic`, which is inspired by a preinstalled theme called [powerlevel10k_classic](https://ohmyposh.dev/docs/themes#powerlevel10k_classic).

{% gist https://gist.github.com/AnsonH/55858833ddcfbb7946f42740ac720cd4 %}

To use my theme:

1. Visit the [GitHub Gist link](https://gist.github.com/AnsonH/55858833ddcfbb7946f42740ac720cd4) and click the “Download ZIP” button at the top right corner.

2. Extract `p10k_classic.omp.json` into a location of your choice. For example, let’s place it in the root folder (`~`).

3. Open Windows Terminal and run `notepad $PROFILE` in Powershell.

4. In the opened file, change the path after `--config` so that it uses `~/p10k_classic.omp.json`
    ```powershell
    oh-my-posh --init --shell pwsh --config ~/p10k_classic.omp.json | Invoke-Expression
    ```

5. Restart your Terminal:
    ![Custom p10k_classic theme](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6w6twlewqnn0cpihtjoq.png)

<hr>

## Winfetch

As an added bonus, we’ll install [winfetch](https://github.com/kiedtl/winfetch), a command-line tool that prints out system information. This is a great alternative to [neofetch](https://github.com/dylanaraps/neofetch), which only works on Linux.

### Setup

[This wiki page](https://github.com/kiedtl/winfetch/wiki/Installation) lists several ways to install winfetch. We’re using the first recommended method: PSGallery.

1. Run Windows Terminal as **administrator**. To do that, search “Windows Terminal” in the Start Menu, right click the item, and press “Run as administrator”
    ![Run as administrator](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kkwnikzfp0d2j5mp97ah.png)
 
2. In Powershell, run the command:
    ```powershell
    Install-Script -Name pwshfetch-test-1
    ```
    
    Choose “Yes” for any prompts you encountered.

3. Run `notepad $PROFILE` to open Powershell profile. Add the following line of code at the end:
    ```powershell
    Set-Alias winfetch pwshfetch-test-1
    ```

4. Restart your Terminal. Then, run `winfetch` to see if it’s correctly installed.
    ![winfetch default configuration](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8qgw3xq95roqwf0z41ae.png)

The default winfetch config is saved to `~\.config\winfetch\config.ps1`. Check out the [“Configuration” wiki page](https://github.com/kiedtl/winfetch/wiki/Configuration) to see all available configuration options.

### Custom Image

The Windows logo at the left can be changed to a custom “image” (more like a low resolution pixel art because Windows Terminal cannot render full resolution images).

For example, I want to display [my GitHub profile picture](https://avatars.githubusercontent.com/u/57580593?v=4), which is a 8-bit Luigi art:

![GitHub avatar](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1shz30r8qtirgbyjfplw.png)

1. Save this image and place it in a location of your choice. For example, I save it at the root folder (`~`) with the name `luigi.png`.

2. Open `~\.config\winfetch\config.ps1` in Notepad. Change the first two variables to the following:
    ```powershell
    # ===== WINFETCH CONFIGURATION =====
    
    $image = "C:\Users\User\luigi.png"  # ABSOLUTE path
    $noimage = $false
    ```

    > ⚠ I used **absolute path** in `$image` because winfetch in my PC is having trouble processing a relative path (`~/luigi.png`). The full path of my root folder is `C:\Users\User`.

3. Save the file and run `winfetch` in Powershell:
    ![winfetch with custom image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rac12jfudd7x4k2m02ef.png)

### More Configuration

By default, winfetch only shows information about your C drive. To show all available drives, open `~\.config\winfetch\config.ps1` and uncomment the field:

```powershell
# Configure which disks are shown
# $ShowDisks = @("C:", "D:")
# Show all available disks
$ShowDisks = @("*")
```

You can also display a bar chart for the memory (RAM) and disk usage:

```powershell
# Configure how to show info for levels
# Default is for text only.
# 'bar' is for bar only.
# 'textbar' is for text + bar.
# 'bartext' is for bar + text.
# $cpustyle = 'bar'
$memorystyle = 'bartext'
$diskstyle = 'bartext'
# $batterystyle = 'bartext'
```

Here’s our final result:

![winfetch final results](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fu9s8q4vjhbv0grr1jzh.png)

<hr>

That’s all the steps you needed to beautify your Terminal 🌈. Now it’s time for you to show off in front of your friends and colleagues! 😁

Thanks for reading! If you find it useful, don’t forget to like and share this post 🙌

- [My GitHub](https://github.com/AnsonH)
- [Personal website](https://www.ansonh.com)