Beautify Your Windows Terminal With posh-git and oh-my-posh

Ansh Badaya
6 min readAug 19, 2021

--

Credit— varonis.com
Your Terminal After Customization And You Can Change It In 30+ Ways.

If you are a programmer or an advanced windows user you should probably use command prompt and powershell a lot.Now the default look of the powershell and command prompt looks quite odd and if you use on a day to day basis I’m sure you don’t like working on it.Also if you use Git then you probably want to have some visual information when you make changes.Now what i am going to show you is how you can add features and beautify your terminal.We will go step-by-step.So let’s get started…

STEP 1 — INSTALL WINODOWS TERMINAL

Go to Microsoft Store -> Search For Windows Terminal -> Click On Get -> Click on Install

Now Windows Terminal is installed in your system and basically what it does is allow you to run all type of shells and to have multiple instances of a particular shell and customizing the shells from here is simple and manageable.

Now Run the windows terminal in your system and it will launch the powershell by default.

STEP 2 — INSTALLING POSH-GIT AND OH-MY-POSH

Run These Three Commands one by one and if you get a prompt of installing some other modules or library in your system then click on that.You have to accept all the permissions and settings that’s get prompted(if any). If you done it correctly you will have all these modules installed in your system.

Install-Module posh-git -Scope CurrentUser

Install-Module oh-my-posh -Scope CurrentUser

Install-Module -Name PSReadLine -Scope CurrentUser -Force -SkipPublisherCheck

The -Scope CurrentUser install these modules only for the current user and not for the whole system and if you want to install it at system level(which i don’t recommend)then remove both the options and then execute the command.

STEP 3 — SAVING THE PROFILE

Now in the same or a new terminal type notepad $profile And Copy,Paste And Save The Following 3 Lines There(In case if you get a prompt to create a new profile,Click on that).

Import-Module posh-git
Import-Module oh-my-posh
Set-PoshPrompt -Theme blueish

STEP 4 — CHANGING THE FONTS

Now you will probably skip this step (thinking the it isn’t required) but you are wrong because in order to get the beautiful shapes and glyphs we need to change our font to any nerd font otherwise we won’t see the proper shapes and glyphs.So go on to ->

https://www.nerdfonts.com/

Find and Download any nerd font of your choice.If you are unable to navigate there then download the following font from github ->

VictorMono Font

Now we need to install the downloaded font in our machine and to do that go to->

C:\Windows\Fonts

Copy and paste the downloaded font here.Windows will ask to install it,click yes and now we have font downloaded in our machine.

STEP 5 — CHANGING THE BACKGROUND AND FONT IN WINDOWS TERMINAL

Open Windows Terminal and then open settings by pressing Ctrl + , or in the top bar ,click the drop-down menu and you will find settings there.Now in the bottom left corner of settings there is a “Open JSON File” option,click on that and put the following 4 lines in the default section.

“acrylicOpacity”: 0.65000000000000002,
“fontFace”: “VictorMono Nerd Font Mono”,
“fontSize”: 14,
“useAcrylic”: true

NOTE -> If you have installed other nerd font then you have to change the “fontface” section’s value to the name of that font(enclosed in “ ”).

Eg . “fontface” : “3270 Nerd Font Mono” if you have installed 3270-Medium Nerd Font Complete Mono.ttf

Now all things are done and you now have a beautiful terminal.And now there are few additional things which i should mention.

  1. You can view all the posh themes by simply typing Get-PoshThemes in the powershell and start looking which theme suits you best.
  2. To set a particular theme for current instance of powershell(it wont replace the powershell theme that we have set),just type Set-PoshPrompt -Theme <ThemeName>.To change it permanently go to step 4.
  3. If you want to change the font (if you don’t like it) then go to Windows Terminal ->Settings ->Open JSON File .In the default section change the fontFace to that font which you like and has been installed in the C:\Windows \Fonts.
  4. If you don’t like the current posh theme then simply change it by first typing notepad $profile and then changing the following field

Replace Set-PoshPrompt -Theme blueish with Set-PoshPrompt -Theme <ThemeName>

Eg. Replace Set-PoshPrompt -Theme blueish with Set-PoshPrompt -Theme iterm2

5. You can also customize the posh themes according to what you like an for it you should know a little bit of JSON.So to to the following location(replace the placeholder with your username) and then just edit it with any text editor of your choice.

C:\Users\<YourUsername>\Documents\WindowsPowerShell\Modules\oh-my-posh\3.169.2\themes

My theme look like this which i have customized :-

Customized iterm2 theme

Link— https://github.com/techlearnme/Medium/blob/main/iterm2.omp.json

6. Themes which recommend is iterm2 , paradox ,powerlevel110k_rainbow ,agnoster ,blueish

Why we use posh-git?

The simplest answer is that it basically put the basic features of git when combined with oh-my-posh themes to give a visual result in the windows.So if we wont use posh-git then we will not be able to see the change in color in the themes if something gets modified.

Why we use oh-my-posh?

We use this to get the themes in the terminal.So all the changed stuff like having the name of the folder in a rectangular box,colors in them etc. etc. is possible due to this and if we don’t use it them our powershell remains as it is with no change in it.

So we need both the libraries but you can skip the posh-git if you are not a developer.

Errors You Might Get ->

  1. The most common error is with fonts,so when we change them and also put their right name in settings JSON file we get an error as we start.So to solve that when you start the terminal it displays an error message saying about the the windows don’t found the particular font so it has set the font for current instance to some particular font having similar name.So what you have ton do is to just rename the fontface to that particular name and then your error will go away.
  2. Another error which users get is to not having the proper glyphs of the posh theme and having question mark in some places and the reason is pretty simple that you have not installed a nerd font and posh theme requires a nerd font in order to work properly.
  3. Your main powershell will look abnormal and just change the font of it also and it will look awesome then.

So i hope that you have successfully done all the steps and having an awesome prompt.Now if you are still facing any issues with the installation then follow this blog and it will help you for sure :)

https://medium.com/analytics-vidhya/customize-your-windows-powershell-with-oh-my-posh-posh-git-93284b2749b6

Happy Coding:)

--

--