Skip to content

Instantly share code, notes, and snippets.

@RomelSan
Last active March 17, 2024 10:38
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save RomelSan/1698b83ad2b07dd8a52e7191d1a0e907 to your computer and use it in GitHub Desktop.
Save RomelSan/1698b83ad2b07dd8a52e7191d1a0e907 to your computer and use it in GitHub Desktop.
Set up Powerline in PowerShell

Set up Powerline in PowerShell

PowerShell prerequisites

Install Windows Terminal: https://github.com/microsoft/terminal/releases
Install Git for Windows: https://git-scm.com/downloads
Install Cascadia Code PL Font: https://github.com/microsoft/cascadia-code/releases

Using PowerShell, install Posh-Git and Oh-My-Posh:

  • Oh-My-Posh provides theme capabilities for your PowerShell prompt.
  • Posh-Git adds Git status information to your prompt as well as tab-completion for Git
Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser

Note: To update a module use the command: Update-Module

If you are using PowerShell Core, install PSReadline:

  • PSReadline lets you customize the command line editing environment in PowerShell.
Install-Module -Name PSReadLine -Scope CurrentUser -Force -SkipPublisherCheck

Customize your PowerShell prompt

  • Open your PowerShell profile with a code editor:
    code $PROFILE
    notepad $PROFILE
    notepad++ $PROFILE
    or the text editor of your choice.
    This is not your Windows Terminal profile.
    Your PowerShell profile is a script that runs every time PowerShell starts.

In your PowerShell profile, add the following to the end of the file:

Import-Module posh-git
Import-Module oh-my-posh
Set-Theme Paradox

Edit Windows Terminal profile:

Open Windows Terminal Settings.

{
    // Make changes here to the powershell.exe profile.
    "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
    "name": "Windows PowerShell",
    "commandline": "powershell.exe",
    "fontFace": "Cascadia Code PL",
    "fontSize" : 11,
    "colorScheme" : "One Half Dark",
    "hidden": false
},

Save the file.
Done

Powershell built-in colorScheme:

  Campbell
  Campbell Powershell
  Vintage
  One Half Dark
  One Half Light
  Tango Dark
  Tango Light
  Solarized Dark
  Solarized Light

Other Stuff

  • List current configuration
    $ThemeSettings

  • Oh My Posh Themes to Try:
    Agnoster
    Paradox
    Robbyrussel
    Pararussel

  • Display the colors used by the theme
    Show-ThemeColors

  • display colors configured in Terminal
    Show-Colors

  • List Themes
    get-theme

Enable the Prompt

  • Start the default settings
    Set-Prompt
  • Alternatively set the desired theme:
    Set-Theme Agnoster

Official Links

https://github.com/microsoft/terminal/releases
https://github.com/JanDeDobbeleer/oh-my-posh
https://github.com/dahlbyk/posh-git
https://github.com/microsoft/cascadia-code/releases
https://git-scm.com/downloads
https://www.powershellgallery.com/packages/oh-my-posh/
https://www.powershellgallery.com/packages/posh-git/
https://www.powershellgallery.com/packages/PSReadLine/

@volkankaban
Copy link

Thanks!

@AlexKler
Copy link

AlexKler commented Jun 2, 2022

Why not update this description? The 'Set-Theme' command has been replaced by 'Set-PoshPrompt' a long time ago. And this is confusing for beginners.

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