Scott Hanselman

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

October 17, '19 Comments [13] 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.

Then from within Windows Terminal, hit "Ctrl+," to edit your profile.json and change the "fontFace" of your profile or profiles to this:

"fontFace":  "Delugia Nerd Font",

And that's it!

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 the 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
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb
Sunday, October 20, 2019 7:57:52 AM UTC
I want this but too lazy to follow Scott's instruction... please somebody package this and let me download with one command... pretty please... 😅
rosdi
Sunday, October 20, 2019 8:00:31 AM UTC
Thank you Scott for this tip

On the Delugia documentation font face is named "Delugia Nerd Font" instead of "DelugiaCode NF"
Pierre-Emmanuel Mercier
Sunday, October 20, 2019 2:32:58 PM UTC
This seems to be a good option as well: https://github.com/andresgongora/synth-shell
Monday, October 21, 2019 9:04:22 AM UTC
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.
Jim Paton
Monday, October 21, 2019 9:38:33 AM UTC
Ignore me. Found the problem!
It seems you need to avoid the "Mono" versions of the fonts for the ligatures to work.
Jim Paton
Monday, October 21, 2019 12:57:41 PM UTC
Yeah, I've always wanted a prompt that constantly takes up 60-70% of the horizontal space of my terminal window! :p
Gumpy Git
Monday, October 21, 2019 1:07:47 PM UTC
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.
Marc
Monday, October 21, 2019 1:58:47 PM UTC
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!
Tuesday, October 22, 2019 12:20:06 PM UTC
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.
Didier Donner
Tuesday, October 22, 2019 6:07:31 PM UTC
Could someone send me a patched Cascadia Code Nerd Fonts font file? Sadly I cannot patched successfully it.
Wednesday, October 23, 2019 3:08:03 PM UTC
Firstly I would like to thanks Scoot.

I am agree your points because I have follow this guidlines.
Wednesday, October 23, 2019 3:47:49 PM UTC
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
Eric Lamontagne
Thursday, October 24, 2019 9:22:16 PM UTC
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?
Adam Carr
Comments are closed.

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