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

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 until /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”: “DelugiaCode NF”,

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!

© 2019 Scott Hanselman. All rights reserved.      

Read more: feeds.hanselman.com

Leave a Reply

Your email address will not be published. Required fields are marked *