Skip to content

Instantly share code, notes, and snippets.

@royz
Last active October 20, 2024 14:34
Show Gist options
  • Save royz/e9a58f794f88ed8f601cbf39530c2936 to your computer and use it in GitHub Desktop.
Save royz/e9a58f794f88ed8f601cbf39530c2936 to your computer and use it in GitHub Desktop.

Installation

Using chocolaty choco install oh-my-posh

USing powershell Install-Module oh-my-posh -Scope CurrentUser

Using winget winget install JanDeDobbeleer.OhMyPosh -s winget


Uninstall modules (optional)

Might need to uninstall existing verson of PSReadLine

  • Run using cmd: powershell -NoProfile -NonInteractive -Command "Uninstall-Module PSReadLine -AllVersions -Force -Verbose"

Install modules

  • Install-Module -Name PSReadLine -RequiredVersion 2.2.2
  • Install-Module -Name Terminal-Icons
  • Install-Module -Name z

Microsoft.PowerShell_profile.ps1

Edit by running code $profile

oh-my-posh init pwsh --config "F:\Others\Termial\powershell\the-unnamed-royz.json" | Invoke-Expression

# remove it first because already imported version clashes with the new verion
Remove-Module -Name PSReadLine

# Install With 'Install-Module -Name PSReadLine -RequiredVersion 2.2.2'
Import-Module -Name PSReadLine

# Install with 'Install-Module -Name Terminal-Icons'
Import-Module -Name Terminal-Icons

# Install with 'Install-Module -Name z'
Import-Module -Name z

# Enable prediction
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -PredictionViewStyle ListView
Set-PSReadLineOption -EditMode Windows

$env:POSH_GIT_ENABLED = $true

Theme (the-unnamed-royz.json)

{
  "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
  "blocks": [
    {
      "alignment": "right",
      "segments": [
        {
          "properties": {
            "always_enabled": true,
            "threshold": 500,
            "style":"roundrock"
          },
          "style": "plain",
          "template": " <#d0d61c>\ufa1e {{ .FormattedMs }}</> ",
          "type": "executiontime"
        }
      ],
      "type": "rprompt"
    },
    {
      "alignment": "left",
      "segments": [
        {
          "foreground": "#2bd0d9",
          "properties": {
            "style": "full"
          },
          "style": "plain",
          "template": "{{ .Path }} ",
          "type": "path"
        },
        {
          "foreground": "#e88412",
          "properties": {
            "branch_icon": "\ue0a0 "
          },
          "style": "plain",
          "template": "{{ .HEAD }}",
          "type": "git"
        }
      ],
      "type": "prompt"
    },
    {
      "alignment": "left",
      "newline": true,
      "segments": [
        {
          "style": "plain",
          "template": "{{ if gt .Code 0 }}<#e93a13>\u276f</>{{ else }}<#12c32f>\u276f</>{{ end }} ",
          "type": "text"
        }
      ],
      "type": "prompt"
    }
  ],
  "version": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment