Installing oh-my-posh using winget

Advocate for better developer's productivity and experience
Documenting my learnings and sharing it
Search for a command to run...

Advocate for better developer's productivity and experience
Documenting my learnings and sharing it
No comments yet. Be the first to comment.
Background Recently, I redesigned my team's pipeline running on a multi-module Maven monorepo using GitLab CI. It wasn't that the previous setup was broken, but my team faced a few persistent issues t
Background At work, there’s some test written where I wanted to query the database (repository) after mockMvc request has been made to verify the result. This is a very simple illustration of what it looks like. @SpringBootTest @AutoConfigureMockMvc ...

It's been a long time coming, but I finally came around to set up MongoDB with replicas for local development. TLDR; clone the repository, run docker compose up -d, and you are good to go! If you want to know more, continue to read below. Context Run...

Context I recently came across TaskFile and wanted to use it to automate some of my workflows, which underlying invokes PowerShell commands. However, I faced several errors while doing so, and this post is to reflect on it, and hopefully help myself ...

Problem I was always out of disk space in my C drive, and even though I clear my stuff often, I notice that my space is never reclaimed, instead, it kept going down. I used WizTree to view which file is taking up my disk space, and I noticed this No...

This is a follow-up blog post to a previous article on enhance your developer experience with Windows Terminal and PowerShell, specifically with regard to the setup of oh-my-posh
Based on the website, the recommended way now is to use winget to install oh-my-posh
wingetis a Windows Package Manager to enables users to discover, install, upgrade, remove and configure applications on Windows 10 and Windows 11 computers
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
VSCodeRemove the following from your profile
Import-Module oh-my-posh line
Set-PoshPrompt night-owl
night-owlRemove %USERPROFILE%\.oh-my-posh from your PATH environment variable
Now, re-launch your PowerShell, it should look plain now

Now that we have removed it, we need to set up oh-my-posh again
Launch PowerShell
Run winget install JanDeDobbeleer.OhMyPosh -s winget

Restart PowerShell terminal
Run oh-my-post --version
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

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.
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 $PROFILEReplace
night-owl.omp.jsonwith your preferred theme

Your theme is now back!
If you have set for .bashrc previously, you might need to update the path
// 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)"
If you have set for WSL (previously)
Launch your terminal
Run
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
# 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

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!