Hello Readers,
In this blog, We will see how to set up a powerline in Windows Terminal. The Windows Terminal is a modern, fast, efficient, powerful, and productive terminal application for users of command-line tools and shells like Command Prompt, PowerShell, and WSL. you can find more info here
Powerline enables to customize the command prompt experience and can also provide git status info with various cool themes.
Steps to Setup powerline
1. Install Powerline font
The need for powerline font is because powerline uses glyphs icons to make your command prompt experience cool. if you don't have Powerline font you might experience some Unicode character on your prompt.
you can find a couple of powerline fonts here or you can use Microsoft's Cascadia Code powerline font and install it on your machine. In this article, we will use Cascadia Code font.
2. Setup powerline for PowerShell in Terminal
First, you need to install two PowerShell modules as follows
Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser
posh-git : this module provides Git status information to your prompt as well as tab completion for Git commands, parameters, remotes, and branch names.
oh-my-posh This module provides themes for your PowerShell
while executing the above commands you might come across some errors related to execution policy because it might happen PSGallary
is not a trusted repository on your machine. To solve this you need to change the execution policy by setting it to RemoteSigned or Unrestricted as follows
Set-ExecutionPolicy Unrestricted
Once you install these modules, you need to open the Windows terminal, and open settings by Ctrl + ,
, -> Open JSON file.
In the Setting file, there are couple of sections like schema, actions, and profiles. the profile section is basically an Array of setting for each shell you set up in Windows Terminal and one Default.
You can add a setting in the default section which is common for all and specific settings in the individual profile of the terminal. Now for Powershell, we need to set up Powerline font as Cascadia Font PL
{
// Add font setting in PowerShell profile
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"fontFace": "Cascadia Code PL",
"hidden": false
},
Now the final step, need to update your PowerShell profile which is accessible via notepad $profile
command on PowerShell, and add below lines
Import-Module posh-git
Import-Module oh-my-posh
Set-PoshPrompt -Theme paradox
Now Restart your terminal and open Windows PowerShell, and You can see powerline powered PowerShell along with git info and Git command auto-completion with Tab.
You can change the themes of your choice by changing the last line in $profile
. you can find available themes using the Get-PoshThemes
command.
If you find this article helpful. please share with others !!