Pretty Powershell in Windows


CATEGORY: Windows


Pretty Powershell in Windows

Author: RyanR407

Posted: October 11, 2024


Introduction

This guide covers the steps to enhance your PowerShell experience using Windows Terminal, the MesloLGS NF font, and oh-my-posh. Follow along to customize your environment for a better development experience. There is a video at the end of the blog article, if you prefer to watch instead of read.

Here is what the updated PowerShell command line shows:

  • The Shell in Dark Blue
  • The Administration Level in Red
  • The Shell Location in Orange
  • The GitHub Status in Yellow
  • The Time that the last action took in Violet
  • The Operating System in Gray
  • The Battery Level in Green
  • The Current Time in Light Blue

Install Windows Terminal

Step 1: Install Windows Terminal and App Installer

Begin by installing Windows Terminal from the Microsoft Store. Windows Terminal provides an enhanced interface for your shell environment.

Install Windows Terminal

Step 2: Install MesloLGS NF Fonts

To get the best PowerShell look, install MesloLGS NF fonts. These fonts are required for displaying the icons used by oh-my-posh themes.

  • Download the fonts from the following link: MesloLGS NF Regular
  • Install the font by opening the file and clicking "Install".

Install MesloLGS NF Font

Step 3: Configure PowerShell Font

Once the font is installed, configure it in PowerShell.

  • Open PowerShell.
  • Right-click on the title bar and select "Properties".
  • Under the "Font" tab, choose "MesloLGS NF".

Open PowerShell Properties

Set PowerShell to Use MesloLGS NF Font

Step 4: Edit Windows Terminal Settings

Next, customize your Windows Terminal by editing the settings.json file.

  • Open Windows Terminal.
  • Click the dropdown and choose "Settings".
  • Open the JSON file by clicking "Open JSON file".
  • Add the following to your PowerShell profile:
  • 
    "colorScheme": "Cobalt2",
    "font": {
      "face": "MesloLGS NF"
    },
          

Edit Windows Terminal Settings

Open PowerShell Settings JSON

Add colorScheme and font to PowerShell Settings JSON

Step 5: Add Color Scheme

To enhance the look of your terminal, add the "Cobalt2" color scheme to your settings.json file.

There are other schemes, feel free to use a different one than Cobalt2, you simply change the colorScheme.

After updating the settings.json, save and close the file.

Cobalt2 Color Scheme code for settings.json:


{
  "name": "Cobalt2",
  "black": "#000000",
  "red": "#ff0000",
  "green": "#38de21",
  "yellow": "#ffe50a",
  "blue": "#1460d2",
  "purple": "#ff005d",
  "cyan": "#00bbbb",
  "white": "#bbbbbb",
  "brightBlack": "#555555",
  "brightRed": "#f40e17",
  "brightGreen": "#3bd01d",
  "brightYellow": "#edc809",
  "brightBlue": "#5555ff",
  "brightPurple": "#ff55ff",
  "brightCyan": "#6ae3fa",
  "brightWhite": "#ffffff",
  "background": "#132738",
  "foreground": "#ffffff",
  "cursorColor": "#f0cc09",
  "selectionBackground": "#18354f"
},
      

Add colorScheme and font to PowerShell Settings JSON

Step 6: Configure oh-my-posh

Finally, install and configure oh-my-posh to enhance your PowerShell terminal prompt.

  • Install oh-my-posh
  • Open PowerShell as an Admin by right clicking on it and clicking "Run as Administrator".
  • Run Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned to allow scripts to run.
  • Then, run New-Item -Type File -Force $PROFILE to create a profile.
  • Then, run notepad $PROFILE to open your profile settings file.
  • Then, add oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\atomic.omp.json" | Invoke-Expression to setup oh-my-posh with the atomic theme.


  • PowerShell updated


    You can also use themes othen than "atomic", check out the complete list here.


  • By following these steps, you will have a fully customized PowerShell environment that looks great and enhances your productivity.

PowerShell updated

Useful Resources

Here are some useful resources based on the topics covered in this article:

Video