# Installing oh-my-posh using winget

This is a follow-up blog post to a previous article on [enhance your developer experience with Windows Terminal and PowerShell](https://bwgjoseph.com/enhance-your-developer-experience-with-windows-terminal-and-powershell), specifically with regard to the setup of `oh-my-posh`

Based on the [website](https://ohmyposh.dev/docs/migrating#install-oh-my-posh), the recommended way now is to use [winget](https://learn.microsoft.com/en-us/windows/package-manager/winget/) to install `oh-my-posh`

> `winget` is a **Windows Package Manager** to enables users to discover, install, upgrade, remove and configure applications on Windows 10 and Windows 11 computers

# Uninstall

First, let's get rid of the old configuration and setup done previously

*   Launch `Powershell`
    
*   Run `Remove-Item $env:POSH_PATH -Force -Recurse`
    
*   Run `Uninstall-Module oh-my-posh -AllVersions`
    
*   Run `code $PROFILE`
    
    *   This will launch your PowerShell profile on `VSCode`
        
*   Remove the following from your profile
    
    *   `Import-Module oh-my-posh` line
        
    *   `Set-PoshPrompt night-owl`
        
        *   Or any profile you have defined previously, in my case, it was `night-owl`
            
*   Remove `%USERPROFILE%\.oh-my-posh` from your `PATH` environment variable
    

Now, re-launch your PowerShell, it should look plain now

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1668095660572/fzBGM7hrZ.png align="left")

* * *

# Installation

Now that we have removed it, we need to set up `oh-my-posh` again

*   Launch `PowerShell`
    
*   Run `winget install JanDeDobbeleer.OhMyPosh -s winget`
    

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1668095755658/ZDrmC9_j5.png align="left")

*   Restart `PowerShell` terminal
    
*   Run `oh-my-post --version`
    
    *   Your version will differ from mine, depending on when you install it
        

```plaintext
PS C:\Users\Joseph> oh-my-posh --version
12.13.1
```

Now that `oh-my-posh` is installed, we have to instruct `PowerShell` to use it

*   Run `code $PROFILE`
    
*   Add `oh-my-posh init pwsh | Invoke-Expression` to the last line of your $PROFILE
    

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1669445656023/fVaJSckCK.png align="left")

What about setting up the theme? It's quite straight forward, upon installation of `oh-my-posh`, it also set up an environment variable `POSH_THEMES_PATH` to point to the location of the themes.

*   Replace `oh-my-posh init pwsh | Invoke-Expression` with `oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\night-owl.omp.json" | Invoke-Expression` in your $PROFILE
    

> Replace `night-owl.omp.json` with your preferred theme

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1669445734025/JHwmtYYtY.png align="left")
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1669445845083/6M0UI1Z9R.png align="left")

Your theme is now back!

## bashrc

If you have set for `.bashrc` previously, you might need to update the path

```bash
// from
eval "$(oh-my-posh --init --shell bash --config ~/.oh-my-posh/themes/night-owl.omp.json)"

// to
eval "$(oh-my-posh --init --shell bash --config ~/AppData/Local/Programs/oh-my-posh/themes/night-owl.omp.json)"
```

## WSL

If you have set for WSL (previously)

*   Launch your terminal
    
*   Run
    

```plaintext
sudo wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-linux-amd64 -O /usr/local/bin/oh-my-posh
sudo chmod +x /usr/local/bin/oh-my-posh
```

And if you are using `zsh` within your `WSL`, remember to update your `.zshrc` config as well

### zshrc

```plaintext
# use vim if you like
nano ~/.zshrc
# place this at the end of the file
# we are referencing to our theme in Windows path
# switch the username to yours
eval "$(oh-my-posh --init --shell zsh --config '/mnt/c/Users/Joseph/AppData/Local/Programs/oh-my-posh/themes/night-owl.omp.json')"
// Reload profile
exec zsh
```

If you face this error `Error: unknown flag: --millis`

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1668097015505/PHuP2Fbjr.png align="left")

This is likely that your configuration is wrong, ensure you point to the correct path in your shell (e.g zsh) config

That should be it. Enjoy your newly setup terminal!
