Scott Hanselman

How to make a pretty prompt in Windows Terminal with Powerline, Nerd Fonts, Cascadia Code, WSL, and oh-my-posh

October 17, 2019 Comment on this post [15] Posted in Open Source | Win10
Sponsored By

I've blogged about Patching the new Cascadia Code to include Powerline Glyphs and other Nerd Fonts for the Windows Terminal but folks have asked very specifically, how do I make my prompt look like that?

Step One - Get the Terminal

Get Windows Terminal free from the Store. You can also get it from GitHub's releases but I recommend the store because it'll stay up to date automatically.

Note that if you were an early adopter of the Windows Terminal and you've released updated beyond 0.5, I'd recommend you delete or zero-out your profiles.json and let the Terminal detect and automatically recreate your profiles.json.

Lovely powerline in Windows Terminal

Step Two for PowerShell - Posh-Git and Oh-My-Posh

Per these directions, install Posh-Git and Oh-My-Posh. This also assumes you've installed Git for Windows.

Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser

Run these commands from PowerShell or PowerShell Core. I recommend PowerShell 6.2.3 or above. You can also use PowerShell on Linux too, so be aware. When you run Install-Module for the first time you'll get a warning that you're downloading and installing stuff from the internet so follow the prompts appropriately.

Also get PSReadline if you're on PowerShell Core:

Install-Module -Name PSReadLine -AllowPrerelease -Scope CurrentUser -Force -SkipPublisherCheck

Then run "notepad $PROFILE" and add these lines to the end:

Import-Module posh-git
Import-Module oh-my-posh
Set-Theme Paradox

Now that word Paradox there is optional. It's actually the name of a theme and you can (and should!) pick the theme that makes you happy and use that theme's name here. I like Agnoster, Paradox, or Fish, myself. Read more over here. https://github.com/JanDeDobbeleer/oh-my-posh

Step Two for Ubuntu/WSL

There's a number of choices for Powerline or Powerline-like prompts from Ubuntu. I like Powerline-Go for it's easy defaults.

I just installed Go, then installed powerline-go with go get.

sudo apt install golang-go
go get -u github.com/justjanne/powerline-go

Add this to your ~/.bashrc. You may already have a GOPATH so be aware.

GOPATH=$HOME/go
function _update_ps1() {
PS1="$($GOPATH/bin/powerline-go -error $?)"
}
if [ "$TERM" != "linux" ] && [ -f "$GOPATH/bin/powerline-go" ]; then
PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi

GOTCHA: If you are using WSL2, it'll be lightning fast with git prompts if your source code is in your Ubuntu/Linux mount, somewhere under ~/. However, if your source is under /mnt/c or /mnt anywhere, the git calls being made to populate the prompt are super slow. Be warned. Do your Linux source code/git work in the Linux filesystem for speed until WSL2 gets the file system faster under /mnt.

At this point your Ubuntu/WSL prompt will look awesome as well!

Powerline in WSL

Fonts look weird? Uh oh!

Step Three - Get a better font

If you do all this and you see squares and goofy symbols, it's likely that the font you're using doesn't have the advanced Powerline glyphs. Those glyphs are the ones that make this prompt look so cool!

Weird fonts

At the time of this writing there is active talk of getting Powerline and other Nerd Fonts into Cascadia Code, the new font that ships with Windows Terminal. In the short term, you can get a forked version of Cascadia Code called Delugia Code and download that.

Cascadia Code has been updated with a PL (Powerline) Glyph version! Go get it at https://github.com/microsoft/cascadia-code/releases and change the fontFace in your settings.json to "Cascadia Code PL"

"fontFace":  "Cascadia Code PL"

Remember also you can get lots of Nerd Fonts at https://www.nerdfonts.com/, just make sure you get one (or generate one!) that includes PowerLine Glyphs.

Have fun!


Sponsor: Suffering from a lack of clarity around software bugs? Give your customers the experience they deserve and expect with error monitoring from Raygun.com. Installs in minutes, try it today!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
October 20, 2019 7:57
I want this but too lazy to follow Scott's instruction... please somebody package this and let me download with one command... pretty please... 😅
October 20, 2019 8:00
Thank you Scott for this tip On the Delugia documentation font face is named "Delugia Nerd Font" instead of "DelugiaCode NF"
October 20, 2019 14:32
This seems to be a good option as well: https://github.com/andresgongora/synth-shell
October 21, 2019 9:04
It looks like the NerdFonts patching process breaks the ligatures - I tried their version of Fira Code and the DelugiaCode font and ligatures were broken for both.
October 21, 2019 9:38
Ignore me. Found the problem! It seems you need to avoid the "Mono" versions of the fonts for the ligatures to work.
October 21, 2019 12:57
Yeah, I've always wanted a prompt that constantly takes up 60-70% of the horizontal space of my terminal window! :p
October 21, 2019 13:07
As others commenten. I downloaded the Font but it didn't work. Looks like the Font is now named "Delugia Nerd Font". When I added "fontFace": "Delugia Nerd Font" in the Windows Terminal config for Powershell core it worked.
October 21, 2019 13:58
Sweet! Working fine under ConEmu here - with Delugia Code set as the console font. For my own preferences, I've added -colorize-hostname (to differentiate environments at a quick glance) and -newline (because this prompts does take some space) to the options. My PS1 ended-up like this and I'm happy for now:
PS1="$($GOPATH/bin/powerline-go -colorize-hostname -newline -error $?)"
For anyone who'd rather have a smaller prompt in a single line, try playing with -condensed and -cwd-max-dir-size N (options described here); myself, I prefer the bigger prompt with a newline. Thanks Scott!
October 22, 2019 12:20
Thanks a lot for the tutorial. I managed to get everything installed and running except the fonts with the Windows Terminal. The font works with Terminus (https://github.com/Eugeny/terminus) with the same PowerShell Core 7.0 preview 4. Kinda odd but I will be fine with Terminus.
October 22, 2019 18:07
Could someone send me a patched Cascadia Code Nerd Fonts font file? Sadly I cannot patched successfully it.
October 23, 2019 15:08
Firstly I would like to thanks Scoot. I am agree your points because I have follow this guidlines.
October 23, 2019 15:47
I'm getting this error: Microsoft.PowerShell_profile.ps1:28 char:26 + $sysuptime = (Get-Date) � [System.Management.ManagementDateTime ... + ~~~ Unexpected token '�' in expression or statement. + CategoryInfo : ParserError: (:) [], ParseException + FullyQualifiedErrorId : UnexpectedToken
October 24, 2019 21:22
Scott, Is there any way, or plans to be able to launch the terminal from the Explorer file menu, and to be able to pin it to the quick launch?
October 11, 2020 2:52
Hi, There's no doubt that your website may be having web browser compatibility problems. When I look at your blog in Safari, it looks fine but when opening in I.E., it's got some overlapping issues. I merely wanted to provide you with a quick heads up! Apart from that, wonderful blog! https://vanzari-parbrize.ro/parbrize/parbrize-lancia.html
October 11, 2020 11:41
Heya! I understand this is somewhat off-topic however I needed to ask. Does operating a well-established blog like yours take a lot of work? I am completely new to operating a blog but I do write in my journal everyday. I'd like to start a blog so I can share my personal experience and thoughts online. Please let me know if you have any ideas or tips for new aspiring bloggers. Thankyou! https://anunturi-parbrize.ro/index.php?cauta=luneta+mazda

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.