12

So I tried installing oh-my-posh for windows with

Install-Module oh-my-posh -Scope CurrentUser

and typed

Get-PoshThemes

to see the available themes which I downloaded. But I got this message

Get-PoshThemes : The term 'Get-PoshThemes' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At line:1 char:1
+ Get-PoshThemes
+ ~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-PoshThemes:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Can anyone help me?

shuto235
  • 121
  • 1
  • 1
  • 3
  • 1
    After instaling, shouldn't you also need to `Import-Module oh-my-posh` and add that command in your `$Profile` ?? See [this](https://zimmergren.net/making-windows-terminal-look-awesome-with-oh-my-posh/) – Theo Dec 13 '21 at 13:07
  • I'm having the same issue... @Theo `Import-Module oh-my-posh` didn't fix it for me. It could be an issue with the latest version-- I'm using 6.42.3. When I get a sec, I'll try the latest commit on the oh-my-posh GitHub repo. – Robbie Capps Dec 30 '21 at 20:02
  • The old solution is deprecated, Try this: https://ohmyposh.dev/docs/migrating – QMaster Apr 24 '23 at 22:59

4 Answers4

14

Solution

(Note: I'm running PowerShell 7.1 LTS)

First, install a Nerd Font:

[skip if you've already done so]

Instructions for installing a Nerd Font:

https://learn.microsoft.com/en-us/windows/terminal/tutorials/custom-prompt-setup#install-a-nerd-font


Then, install oh-my-posh:

1. Install: posh-git oh-my-posh:

   # This first step isn't included in the Microsoft Docs page:
   Install-Module posh-git -Scope CurrentUser
   
   # ...though this one is:
   Install-Module oh-my-posh -Scope CurrentUser

2. ...follow the rest of the instructions here:

https://github.com/JanDeDobbeleer/oh-my-posh2#installation

3. ...finally, try the command again:

   # Set the prompt theme (defaults to 'agnoster' for me)
   # ! Note: You have to do this step first (or it still won't work)
   Set-PoshPrompt

   # List the available themes (should work now)
   # ! Note: this will attempt to render a bunch of graphics in your shell
   Get-PoshThemes
   
   # ! Note: use the -List option to avoid a bunch of graphics in your shell
   # This will list the paths to the themes (in plaintext):
   Get-PoshThemes -List

Optional

To avoid manually entering Set-PoshPrompt, include the command in your PowerShell $PROFILE:

    # ...e.g. to use the included 'zash' theme:
    Set-PoshPrompt zash

...you should see your PowerShell prompt change when you open a start shell instance (i.e. new PowerShell tab or window).


Closing thoughts (side-note)

Before I got it to work, I originally followed the instructions here:

https://learn.microsoft.com/en-us/windows/terminal/tutorials/custom-prompt-setup#install-a-nerd-font

...no mention of the posh-git module or the Set-PoshPrompt command (as of 12/30/2021).

Robbie Capps
  • 417
  • 1
  • 5
  • 16
  • Hi, I followed first Microstoft guide than yours (and what is in GitHub) but doesn't work for me. When trying to run Set-Prompt I just get an error: The term 'Set-Prompt' is not recognized as the name of a cmdlet. Any tips how to deal with that? – GKroch May 11 '22 at 11:02
  • @GKroch By `Set-Prompt`, do you mean `Set-PoshPrompt`? Apologies, I had a typo in one part of my answer (now fixed). – Robbie Capps May 11 '22 at 20:37
0

I kept getting the cmdlet not found error even after following the guide by Robbie. For some reason a fresh install did not fix it for me but an update did:

Update-Module oh-my-posh
Brad C
  • 2,868
  • 22
  • 33
0

I following with docs from ohmyposh and it working with me

  • 1
    ... what exactly from it did you follow? Are you referring to specific part or the whole thing? see also https://meta.stackexchange.com/a/8259/997587 – starball Jun 22 '23 at 05:44
  • Please provide proper solution to the question – Hrishikesh Jun 24 '23 at 13:35
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/34582770) – ryanwebjackson Jun 27 '23 at 12:18
-1

You can start your vs code by admin permissions and it will be fixed. I'm using oh-my-posh version 14.29.1

RezaPanahi
  • 11
  • 1
  • This is a workaround and not a safe one. If you make a mistake or your profile is compromised, there's signficantly less protection from 'bad things' happening. The oh-my-posh installation instructions work, if you follow them. – Jeter-work Apr 13 '23 at 18:16