DEV Community

Vipul Dessai
Vipul Dessai

Posted on • Edited on

Oh my posh on all windows terminals (vs code integrated terminal too!!)

vs code integrated terminal with oh my posh

Set Permission in Windows Powershell

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Enter fullscreen mode Exit fullscreen mode

also open the VS code and open the terminal and use the same command to set policy in the VS code terminal

Install the 'oh my posh'

by either visiting this or use the below command.

winget install JanDeDobbeleer.OhMyPosh -s winget
Enter fullscreen mode Exit fullscreen mode

Install fonts

oh-my-posh font install meslo
Enter fullscreen mode Exit fullscreen mode
  • 'meslo' worked well for all themes i tested, if the theme text is breaking try using other font

Edit the terminal configs

Modify the settings.json of the terminal

  • open the terminal as an admin user
  • press CTRL + SHIFT + ,
  • this will open or prompt to select your favorite editor for the 'settings.json'
"profiles": 
    {
        "defaults": {
            "font":
            {
                "face": "MesloLGM Nerd Font"
            }
        }
    ...
Enter fullscreen mode Exit fullscreen mode
  • save it

Modify the settings of VS code integrated terminal

  • go to File -> Preferences -> Settings
  • search for @feature:terminal font
  • add the font 'MesloLGM Nerd Font'
  • save it (CTRL + S)

Install the theme - [official documentation]

Create a profile file

Create a new profile file manually

  • create a file
  • rename it to Microsoft.PowerShell_profile.ps1
  • move it to C:\Users\<user-name>\OneDrive\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

Automatically create a profile file

  • open the terminal
  • create a new profile by running the following command
New-Item -Path $PROFILE -Type File -Force
Enter fullscreen mode Exit fullscreen mode
  • this will create a file at C:\Users\<user-name>\OneDrive\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

Add the content to the profile file

  • for example I'll use '1_shell' theme
  • add the below line to the newly created profile file
oh-my-posh init pwsh --config 'https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/1_shell.omp.json' | Invoke-Expression
Enter fullscreen mode Exit fullscreen mode
  • replace 1_shell.omp.json with the omp.json of the desired theme name
    • theme name can be found here
  • restart the terminal

Note: if no --config flag is provided then the default theme will be used

That's it, now you are a 10X developer 😝

Top comments (2)

Collapse
 
souleymanesy7 profile image
Souleymane Sy

I am getting an Error When I restart the Windows Powershell.
The $PROFILE is not Loading

Collapse
 
badgamerbad profile image
Vipul Dessai

looks like some misconfiguration that you did while setting up the $profile, check the content of it