Enhanced Windows Terminal with Folder Icons
Tags: windows, terminal, productivity
Published: 2021-12-28 22:48:50

This will be a short tutorial on how to enhance Windows Terminal to make it more appealing and easier to read.

Let's keep it simple.

---

### Install oh-my-posh

Open Windows Terminal, access PowerShell profile, and enter these lines

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

// optional
Install-Module posh-git -Scope CurrentUser
```

> *I'm using [PowerShell v7.2](https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.2#msi)*

---

### Install fonts

You can use any of these fonts because they support icons and ligatures used in the themes. I used `CaskaydiaCove NF` since some of the fonts have wierd lines around the leading and trailing symbols.

[NerdFonts](https://www.nerdfonts.com/font-downloads)

---

### Display installed themes

This will display all official themes with styling, and when you find the one that suits, you have to update `$PROFILE` script again

```java
Get-PoshThemes
```

I am using `clean-detailed` theme so we will just add it's name. Again `notepad $PROFILE` and append this line

```java
Set-PoshPrompt -Theme clean-detailed
```

---

### Theme configuration file
All installed theme configuration files are located in `%LOCALAPPDATA%\Programs\oh-my-posh\themes`, so go there and copy the configuration file of your selected theme, in my case it's `clean-detailed.omp.json`.

Paste the copied file to ex. `C:\omp-config.omp.json` and update our shell configuration by entering this in our `$PROFILE` script

```javascript
oh-my-posh --init --shell pwsh --config C:\config.omp.json | Invoke-Expression
```
This will update shell configuration, and after this we need to reload `$PROFILE` script, so just run this

```java
. $PROFILE
```

---

### Install icons

If you want folder icons to be visible run this script

```java
Install-Module -Name Terminal-Icons -Repository PSGallery
```
after this, as usual, we need to update `$PROFILE` script, so enter `notepad $PROFILE` powershell to edit and append this to end of the file

```java
Import-Module -Name Terminal-Icons
```

---

### Final layout

This is our `$PROFILE` configuration

```javascript
Import-Module posh-git
Import-Module oh-my-posh
Import-Module Terminal-Icons
Set-PoshPrompt -Theme clean-detailed
oh-my-posh --init --shell pwsh --config C:\config.omp.json | Invoke-Expression
```

You can basically customize everything from this point, but this is the layout that we got from just entering couple of lines, and I think it's far better than plain Windows Terminal. 

[Ohmyposh](https://ohmyposh.dev/docs/windows) has comprehensive documentation on how and what you can stylize

![Final layout](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qyd9wmg1hgz5pdjes9b4.png)

After all this you should be setting this as your default profile in Windows Terminal by editing configuration file as follows

```json    
"defaultProfile": "{your-powershell-profile-guid}",
        "defaults": 
        {
            "antialiasingMode": "cleartype",
            "experimental.retroTerminalEffect": false,
            "font": 
            {
                "face": "CaskaydiaCove NF",
                "size": 12,
                "weight": "medium"
            },
            "intenseTextStyle": "bright",
            "padding": "20",
            "snapOnInput": true,
            "startingDirectory": "%__CD__%",
        },
```

---

For better experience install [PSReadLine](https://github.com/PowerShell/PSReadLine) module that has a lot of improvement style and accessibility wise

```java
Install-Module PSReadLine -AllowPrerelease -Force
```

And update profile again, `notepad $PROFILE`
```java
Import-Module PSReadLine
```

---

If you want to use oh-my-posh outside of powershell, you have to add it to `$PATH` env variable. 

Just enter this line

```java
$env:PATH += $env:POSH_PATH
```

Also, if you want to exclude version and intro text of powershell, just add `/nologo` in settings GUI or append in powershell profile directly (settings.json):

```javascript
{
 "commandline": "C:\\Program Files\\PowerShell\\7\\pwsh.exe /nologo", // here
 "guid": "{your-guid}",
 "hidden": false,
 "name": "PowerShell",
 "source": "Windows.Terminal.PowershellCore"
},
```

---

### Resources

[Oh-my-posh docs](https://ohmyposh.dev/docs/windows)

[Windows Terminal docs](https://docs.microsoft.com/en-us/windows/terminal)