Leveling up Windows Powershell with Oh My Posh
20 May, 2022
I was sitting on YouTube the other day and looking for a quick productivity win, and I stumbled across Scott Hanselman’s video on making the ultimate Windows Terminal. I’ve recently started doing more web and game development on my Windows machine, so I thought I’d give it a shot and see how much better my shell experience could get.
After watching 15 minutes of his video, I was hooked and already tweaking and customizing my theme to my exact needs.
I thought I’d write about my process and the steps I took to get to my final Terminal setup. The process was similar to “oh my zsh” on Mac if you’re familar with that.
First things first, we need PowerShell. This will work with other shells, but to make this process simple, we’ll start with PowerShell.
Windows 10 comes with a “Windows Powershell”, but it’s not the same as Powershell. You’ll need to download a separate shell if you haven’t already:
Oh My Posh
Like oh my zsh for Mac, but for PowerShell. Styles your Powershell and displays extra info (like current Github branch).
- Make sure Powershell is installed (see top of this page)
- Install oh-my-posh. I used the manual method.
- Restart your Powershell (or Windows Terminal).
- You should see it! But with broken fonts and missing glyphs…
- Install special fonts from NerdFont (basically fonts + glyphs like FontAwesome).
- You can usually find your favorite coding font (like Fira Code or Jet Brains Mono)
- Go to Windows Terminal settings, select Powershell settings, go to Appearance, and change font to the one you downloaded - it will end in
- You’ll also want to do this for Visual Studio Code if you plan to use the integrated shell/console.
- Now things should look correct! 🎆
Browse all the themes here or run
Get-PoshThemes. The default themes come pre-installed with oh-my-posh in the
Install the theme by opening your
.bashrc for WSL) and changing the
oh-my-posh initialization we added earlier with your theme config. Here you can see we’re installing one of the default themes - Night Owl:
oh-my-posh init pwsh --config $env:POSH_THEMES_PATH\night-owl.omp.json | Invoke-Expression
I created a theme based on
powerlevel10k_modern and took some modules from
night-owl like the CPU monitor, Node version, and PHP version.
3rd Party Plugins
These are extra sprinkles on top of Windows Terminal that help enhance the experience (like adding icons or autocomplete to commands).
Autocomplete using history
Predictive intellisense based off your shell history - like a smart search. So if you go to certain folders often, they’ll pop up in the list as you type.
- Install the prelease of the module (requires 2.2.0-beta1 or greater as of 5/17/2022):
Install-Module -Name PSReadLine -AllowPrerelease -Scope CurrentUser -Force -SkipPublisherCheck
- Add this to your
# Add auto complete (requires PSReadline 2.2.0-beta1+ prerelease)Set-PSReadLineOption -PredictionSource HistorySet-PSReadLineOption -PredictionViewStyle ListViewSet-PSReadLineOption -EditMode Windows
This wasn’t as simple as the commands sometimes (go figure with prerelease lol) - but these resources helped get things working.
These are nice icons for the different folders and files you have in development projects. If you’ve used VSCode and installed any icon extensions, you’re probably familiar with this.
- Run this command to install the module:
Install-Module -Name Terminal-Icons -Repository PSGallery
- Add this to your
Import-Module -Name Terminal-Icons
- Refresh your PS config by running:
- Try running
dirto see the icons!
Thanks again to Scott Hanselman for the tip!:
My Final Configuration
For reference, here is the final configuration file for my Windows Terminal (aka
$PROFILE). I also added some comments that go over the installation of plugins/modules I mentioned above (just in case).
What’s your shell look like?
Now that I’ve dipped my toe in the shell customization water, I’m definitely looking for more inspiration to improve my setup and make it even better. Hit me up on Twitter and share your shell setup, I’d love to see it.