Tutorial: Set up Powerline in Windows Terminal
Powerline provides a customized command prompt experience providing Git status color-coding and prompts.
In this tutorial, you learn how to:
- Set up Powerline in PowerShell
- Set up Powerline in Ubuntu/WSL
- Add missing Powerline glyphs
Prerequisites
Install a Powerline font
Powerline uses glyphs in order to style the prompt. If your font does not include Powerline glyphs, you may see several Unicode replacement characters '▯' throughout your prompt. Though Cascadia Mono does not include Powerline glyphs, you can install Cascadia Code PL or Cascadia Mono PL, which have the Powerline glyphs included. These fonts can be installed from the Cascadia Code GitHub releases page.
Set up Powerline in PowerShell
PowerShell prerequisites
If you don't already have it, install Git for Windows.
Using PowerShell, install Posh-Git and Oh-My-Posh:
Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser
Tip
You may need to install NuGet if you don't already have it. Your PowerShell command line will ask if you want to install NuGet if this is the case. Select [Y] Yes. You may also need to approve that you are installing modules from PSGallery, an 'untrusted repository'. Select [Y] Yes.
Posh-Git adds Git status information to your prompt as well as tab-completion for Git commands, parameters, remotes, and branch names. Oh-My-Posh provides theme capabilities for your PowerShell prompt.
If you are using PowerShell Core, install PSReadline:
Install-Module -Name PSReadLine -Scope CurrentUser -Force -SkipPublisherCheck
PSReadline lets you customize the command line editing environment in PowerShell.
Customize your PowerShell prompt
Open your PowerShell profile with notepad $PROFILE
or the text editor of your choice. This is not your Windows Terminal profile. Your PowerShell profile is a script that runs every time PowerShell starts. Learn more about PowerShell profiles.
In your PowerShell profile, add the following to the end of the file:
Import-Module posh-git
Import-Module oh-my-posh
Set-Theme Paradox
Now, each new instance starts by importing Posh-Git and Oh-My-Posh, then setting the Paradox theme from Oh-My-Posh. Oh-My-Posh comes with several built-in themes.
Set Cascadia Code PL as fontFace in settings
To set the Cascadia Code PL font for use with PowerLine (after downloading, unzipping, and installing on your system), you will need to open your profile settings in your settings.json file by selecting Settings (Ctrl+,) from your Windows Terminal drop-down menu.
Once your settings.json file opens, find the Windows PowerShell profile and add: "fontFace": "Cascadia Code PL"
to designate Cascadia Code PL as the font. This will provide those nice Cascadia Code Powerline glyphs. You should notice the change in your terminal as soon as you select Save in your editor.
Your Windows PowerShell profile settings.json file should now look like this:
{
// Make changes here to the powershell.exe profile.
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"fontFace": "Cascadia Code PL",
"hidden": false
},
Tip
If you also use the integrated terminal in Visual Studio Code, you should add "terminal.integrated.fontFamily": "Cascadia Code PL"
to your Visual Studio Code settings to make sure Powerline works there as well.
Set up Powerline in WSL Ubuntu
WSL Ubuntu prerequisites
Ubuntu has several Powerline options to install from. This tutorial will be using Go and Powerline-Go:
sudo apt install golang-go
go get -u github.com/justjanne/powerline-go
Customize your Ubuntu prompt
Open your ~/.bashrc
file with nano ~/.bashrc
or the text editor of your choice. This is a bash script that runs every time bash starts. Add the following, though beware that GOPATH may already exist:
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