Skip to content

Instantly share code, notes, and snippets.

@sahildeshp
Last active March 20, 2025 21:55
Show Gist options
  • Select an option

  • Save sahildeshp/2feaaedf47b9cff80123f798e73fb403 to your computer and use it in GitHub Desktop.

Select an option

Save sahildeshp/2feaaedf47b9cff80123f798e73fb403 to your computer and use it in GitHub Desktop.
Setting up PowerShell 7.x on a new machine

Setting up PowerShell on a new Windows Machine

image

- Install Terminal

https://github.com/microsoft/terminal/releases


- Inside terminal, open the Windows Powershell and use the following to install the latest version of PowerShell

winget install --id Microsoft.PowerShell --source winget

- Use Ctrl + , to open Terminal settings. Go to Startup and make the Default profile Powershell and make the Default terminal application Windows Terminal

image

- Restart Terminal, it should open with PowerShell by default


- Run the following in PowerShell to create the Microsoft.PowerShell_profile.ps1 file for PowerShell 7.x in the correct path

if (!(Test-Path $PROFILE)) { New-Item -Path $PROFILE -ItemType File -Force }

- Run command $PROFILE on PowerShell to the get path for the profile.ps1 file

image


- From the Terminal settings, Open settings.json, navigate to the profiles section

- Set the "hidden" attribute to true to hide all the unrequired profiles


- Install the OhMyPosh Prompt Engine

winget install JanDeDobbeleer.OhMyPosh -s winget

Refer: https://ohmyposh.dev/docs/installation/windows


- Install the CaskaydiaCove Nerd Font

https://www.nerdfonts.com/font-downloads


- Go to Terminal Settings > PowerShell > Appearance and select the CaskaydiaCove Nerd Font as the Font face

- The nerd font is required to see the glyphs

image


- Create YourTheme.omp.json file and put it in C:\Users\YourUserName\AppData\Local\Programs\oh-my-posh\themes

- Following is my .omp.json file

{
  "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
  "blocks": [
    {
      "alignment": "left",
      "segments": [
        {
          "foreground": "#ffffff",
          "properties": {
            "time_format": "15:04"
          },
          "style": "plain",
          "template": " {{ .CurrentDate | date .Format }} ",
          "type": "time"
        },
        {
          "background": "#ffffff",
          "foreground": "#100e23",
          "powerline_symbol": "\ue0b0",
          "style": "powerline",
          "template": " {{ .UserName }} ",
          "type": "session"
        },
        {
          "background": "#91ddff",
          "foreground": "#100e23",
          "powerline_symbol": "\ue0b0",
          "properties": {
            "folder_icon": "\uf115",
            "folder_separator_icon": " \ue0b1 ",
            "home_icon": "~",
            "style": "agnoster"
          },
          "style": "powerline",
          "template": " {{ .Path }} ",
          "type": "path"
        },
        {
          "background": "#95ffa4",
          "foreground": "#193549",
          "powerline_symbol": "\ue0b0",
          "style": "powerline",
          "template": "{{ if .UpstreamIcon }}{{ .UpstreamIcon }} {{ end }} {{ .HEAD }}{{ if .Working.Changed }} \uf044{{ end }}{{ if .Ahead }} \u2191{{ .Ahead }}{{ end }}{{ if .Behind }} \u2193{{ .Behind }}{{ end }} ",
          "type": "git",
          "properties": {
            "fetch_status": true,
            "fetch_upstream_icon": true
          }
        },
        {
          "background": "#ff0000",
          "foreground": "#ffffff",
          "powerline_symbol": "\ue0b0",
          "style": "powerline",
          "template": " \u2717 ",
          "type": "exit",
          "properties": {
            "always_enabled": false
          }
        },
        {
          "background": "#ff4444",
          "foreground": "#ffffff",
          "powerline_symbol": "\ue0b0",
          "style": "powerline",
          "template": " \uF0AD ",
          "type": "root"
        }
      ],
      "type": "prompt"
    }
  ],
  "final_space": true,
  "version": 3
}

- Install Terminal Icons

Install-Module -Name Terminal-Icons -Repository PSGallery

This will make the terminal display icons like shown below: image


- Open the PowerShell profile.ps1 and add the following

Clear-Host
oh-my-posh init pwsh --config C:\Users\UserName\AppData\Local\Programs\oh-my-posh\themes\YourTheme.omp.json | Invoke-Expression
Import-Module -Name Terminal-Icons
Clear-Host

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment