Skip to content

Instantly share code, notes, and snippets.

@TheGU
Last active March 26, 2022 10:09
Show Gist options
  • Save TheGU/149d07934d2a3c4d334a8dfbf2872861 to your computer and use it in GitHub Desktop.
Save TheGU/149d07934d2a3c4d334a8dfbf2872861 to your computer and use it in GitHub Desktop.
Setup Oh-My-Posh powerline on Windows 10

Update: official manual

Step

  1. Open powershell in Admin mode then run Set-ExecutionPolicy Unrestricted

  2. Open powershell (without admin) Installing Posh-Git and Oh-My-Posh. Open Powershell then run

    Install-Module posh-git -Scope CurrentUser
    Install-Module oh-my-posh -Scope CurrentUser
    
  3. Download and Install font from https://github.com/microsoft/cascadia-code/releases (Release Zip file) (CascadiaCodePL.ttf and CascadiaMonoPL.ttf ) then in Windows Terminal go to Setting > Power Sehll > Appearance > Font face change font to Cascadia Code PL then click save I like Caskaydia Cove Nerd Font https://www.nerdfonts.com/, which has the font name CaskaydiaCove NF when configuring it in the Windows Terminal font settings.

  4. In powershell run command notepad $profile to setup profile script. If you don't have any profile, notepad will ask to create new file. Then input below config to profile file

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

    This imports the modules posh-git and oh-my-posh and sets the theme to Paradox every time we start PowerShell. There are many themes to choose from https://ohmyposh.dev/ (or from source https://github.com/JanDeDobbeleer/oh-my-posh) or run Get-PoshThemes to display all theme on current Powershell

  5. In vscode change setting search Font Family then put 'Cascadia Code PL' in font config or

    "terminal.integrated.fontFamily": "Cascadia Code PL",
    "terminal.integrated.profiles.windows": {
      "PowerShell": {
        "source": "PowerShell",
        "icon": "terminal-powershell",
        "args": ["-NoLogo"]
      },
    },
    "terminal.integrated.defaultProfile.windows": "PowerShell",
    

Theme Customize

  1. Export current theme to json file
    oh-my-posh config export --output ~/.mytheme.omp.json
    
  2. Customize json as you see fit. You can get the idea or example from https://ohmyposh.dev/docs/themes. Click on each theme's name to view json config.
  3. Alter profile setting to load new theme. Replace Set-PoshPrompt -Theme paradox with oh-my-posh init pwsh --config ~/.jandedobbeleer.omp.json | Invoke-Expression. Profile file will look like this.
    Import-Module posh-git
    Import-Module oh-my-posh
    oh-my-posh init pwsh --config ~/.jandedobbeleer.omp.json | Invoke-Expression
    
  4. Load new profile
    . $PROFILE
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment