DEV Community

loading...

Pamper your windows terminal - Customize Prompt

debashish2014 profile image Debashish Pal ・3 min read

Windows Terminal (WT) came as a revolution. It was a refreshing delight for all those windows users, who used to stare at the Linux Terminal and wished, can we have it on windows, until now.

Love for Windows Terminal !!

Those who have not tried, what are you waiting for. Give it a try. Trust me it's a game changer.
https://www.microsoft.com/en-in/p/windows-terminal/9n0dx20hk701?activetab=pivot:overviewtab

WT supports Windows PowerShell (Old one that comes installed with windows by default), PowerShell, WSL, CMD, Azure CLI etc. So, whatever terminals are installed on you machine, are all integrated under one roof, which you can choose from the drop-down, as you can see in the image below.

Alt Text

Can we make the terminal look even better like this, with a fancy prompt? YEAH !!

Alt Text

Please follow the steps below:

Note: A separate article will be posted soon for WSL users

For Windows Powershell & Powershell Only

  1. Install Git for Windows from
    https://git-scm.com/downloads

  2. Run below command on the command prompt

This would install post-git & oh-my-posh

Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser
Enter fullscreen mode Exit fullscreen mode

Script execution policy must be set to either RemoteSigned or Unrestricted in order for the profile script to run.

Run this command to check your current execution policy.

Get-ExecutionPolicy
Enter fullscreen mode Exit fullscreen mode

Run the below command for setting it.

Set-ExecutionPolicy Unrestricted -Scope CurrentUser
Enter fullscreen mode Exit fullscreen mode

If it does not work you can try the Force flag.

Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
Enter fullscreen mode Exit fullscreen mode

Posh-Git adds Git status information to your prompt and tab completion for Git commands, parameters, remotes, and branch names.

Oh-My-Posh provides theme capabilities for your PowerShell prompt.

3.Now, we need to add some lines to your profile, which would be executed every time you open a new tab.

Type the below command on the command prompt

notepad $PROFILE
Enter fullscreen mode Exit fullscreen mode

It will open up the profile file in notepad. If a profile file does not exist, it will create a new one. If it exists then same will open.

Add below lines to the end of the file, and Save. The file might be empty initially.

Import-Module posh-git
Import-Module oh-my-posh
Set-PoshPrompt -Theme paradox
Enter fullscreen mode Exit fullscreen mode

4.Now we need to add the required fonts

Download Meslo, and save it at a convenient location.

Navigate to the path were the file was downloaded. Unzip Meslo.zip and install the highlighted fonts as shown below.

Alt Text

Double click each of the font file and install.
Click the Install button on the window which pops up for the same, as shown below.

Alt Text

5.Let's perform the last step.

Open up settings in WT.

Alt Text

It will open up settings.json file in the default editor.

Add below lines to the defaults section.

"fontSize": 9,
"fontFace": "MesloLGM NF"
Enter fullscreen mode Exit fullscreen mode

Alt Text

If you are using latest version of WT, you might get the below screen.

Alt Text

Don't fret, click on the gear icon as shown above. It will open up settings.json file.

That's It !!

You have patiently followed all the steps.

Enjoy your terminal.

Tip !!

If you want to list down all the themes supported by Oh My Posh, run the below command.

 Get-PoshThemes 
Enter fullscreen mode Exit fullscreen mode

You will get output like below

Alt Text

Alt Text

If you wish to change a theme, open up the profile file, and change the theme name.

Ex. If I want to change the theme to bubbles

Type below command on the command prompt to open up profile

notepad $PROFILE
Enter fullscreen mode Exit fullscreen mode

Change the theme name to bubbles as shown below, and save the file.

Alt Text

Open up another tab now, the theme would be applied.

Alt Text

Repeat the steps for each of the terminals

For WSL, WSL2 I will be adding another post soon.

Enjoy the customization !!

Discussion (3)

Collapse
thebarefootdev profile image
thebarefootdev

All very involved and clunky. I’d recommend stop hankering after Linux. If you want Linux then swap if not Microsoft has very cleverly given you the Linux Subsystem on Windows. Now you can have all your Nix goodies without dropping your beloved Windows

Collapse
debashish2014 profile image
Debashish Pal Author

Agreed, but with WT you can have all the terminals at one place including WSL. So, Microsoft is giving you the flexibility to use WSL within WT, without leaving the window. It also has TMUX (linuxhandbook.com/tmux/) like functionality inbuilt. Don't you think it is handy? Moreover, the same setup would apply to WSL also to have the fancy prompt. We still need to install oh-my-posh on it, for the same. We can even install oh-my-zsh (ohmyz.sh/) if we are using zsh. I am not advocating about using powershell or any specific terminal. It is up to users liking, anyways.

Collapse
thebarefootdev profile image
thebarefootdev • Edited

I’m a Nix user, haven’t used Windows in aeons

As for pimping my shell, don’t feel the need to. Starship of if I must or my custom zsh config but not really need to it does what I need.

Forem Open with the Forem app