Windows PowerShell doesn’t come with any git command utilities. But we can extend it to a new level where we can utilize git commands efficiently. In this post, we are going to see how to add auto command suggestions on
TAB, branch information, and a working directory in Windows PowerShell.
The following will be the outcome after following this guide.
Need PowerShell Gallery
To get that look at our default PowerShell, we will install two packages from PowerShell Gallery. To check what that Gallery is about click here. We will install
oh-my-posh packages as modules. The posh-git will provide prompt with Git status summary information and
TAB completion for Git commands, parameters, remotes, and branch names. On the other hand,
oh-my-posh will enable us to theme our terminal as our own.
By default, windows don’t have any package provider for PowerShell modules. If we run the following command, the package provider will automatically get installed. So let’s open the PowerShell and run those commands one after another. It will ask for our confirmation to install the packages. Type
Y for affirmation and type
A to make all upcoming prompt affirmative.
Install-Module posh-git -Scope CurrentUser Install-Module oh-my-posh -Scope CurrentUser
Find A Font With Ligatures
Next, we need a typographic ligature supported font for our terminal. We will set that font from VSCode settings. Why do we need that? We need that to show the current branch, current changes status, etc. related symbols in the terminal. In this case, the Fira Code will be our best option. March ahead and download Fira Code from here. We need the TTF types so open the
ttf folder and install all the fonts.
Set Execution Policy To Unrestricted
There is an execution policy for the security strategy of the PowerShell. We will need to execute some scripts every time we run our terminal. We are going to set these scripts into PowerShell profile so that system will automatically run those scripts for us. To run those scripts, the execution policy has to be unrestricted. To do so we need to open PowerShell in admin privilege and run the following:
There will be a warning prompt for confirmation to change the execution policy. Type
A to choose all affirmative and hit enter!
If you do not have Git installed already, please do so!
Set The Font In VSCode Terminal
We are going to use PowerShell as VSCode terminal. Before doing that we need to change the default font family of the terminal of VSCode to Fira Code. To change the font family open VSCode settings JSON and add the following:
"terminal.integrated.fontFamily": "'Fira Code'"
Create PowerShell Profile
We need the tell the system to set a specific profile before opening the PowerShell. We can do it by writing a small script. To run this script we had to set the execution policy unrestricted. We will import posh-git and oh-my-posh module into that profile along with a theme. This is the list of themes that can be applied. Open PowerShell and run
notepad $PROFILE to create a profile. If there was no profile previously created, then the system will ask to create one. Then add the following script to it and save.
Import-Module posh-git Import-Module oh-my-posh Set-Theme Agnoster
Now it’s time to open the VSCode. Let’s press
CTRL + ` to start the VSCode terminal. Choose PowerShell from the Dropdown if anything else is selected. Now we are ready to with our new terminal!