powershellcommand-promptwindows-terminaloh-my-posh

Windows terminal displays "PS>" instead of the path


I am setting up a new computer and can't get my oh-my-posh configuration working on my Powershell terminal. Powershell v7.4 is installed.

I have copied this across from my previous PC which is displaying correctly.

Profile ps1 (from code $PROFILE):

oh-my-posh --init --shell pwsh --config "C:\dropbox\oh-my-posh\themes\mytheme.omp.json" | Invoke-Expression
Import-Module -Name Terminal-Icons
$env:POSH_GIT_ENABLED = $true

Omp file:

    {
  "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
  "blocks": [
    {
      "alignment": "left",
      "segments": [
        {
          "background": "#1478DB",
          "foreground": "#000000",
          "leading_diamond": "\ue0b6",
          "trailing_diamond": "\uE0B0",
          "properties": {
            "style": "full"
          },
          "style": "diamond",
          "template": "{{ .Path }} ",
          "type": "path"
        },
        {
          "background": "#3AD900",
          "background_templates": [
            "{{ if or (.Working.Changed) (.Staging.Changed) }}#FFC600{{ end }}",
            "{{ if and (gt .Ahead 0) (gt .Behind 0) }}#FFCC80{{ end }}",
            "{{ if gt .Ahead 0 }}#B388FF{{ end }}",
            "{{ if gt .Behind 0 }}#B388FF{{ end }}"
          ],
          "foreground": "#000000",
          "leading_diamond": "<transparent,background>\uE0B0</>",
          "trailing_diamond": "\ue0b4",
          "properties": {
            "fetch_stash_count": true,
            "fetch_status": true
          },
          "style": "diamond",
          "template": " {{ .HEAD }}{{ if .Staging.Changed }}<#FF6F00> \uf046 {{ .Staging.String }}</>{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if gt .StashCount 0 }} \ueb4b {{ .StashCount }}{{ end }} ",
          "type": "git"
        }
      ],
      "type": "prompt"
    }
  ],
  "final_space": true,
  "version": 2
}

Display (working on PC #1): enter image description here

Display (not working on new PC #2): enter image description here

On the new PC I'm only seeing PS> and the command prompt.

If I run oh-my-posh --init --shell pwsh --config "C:\dropbox\oh-my-posh\themes\cobalt2.omp.json" | Invoke-Expression on the command line then the correctly formatted path appears for a short time, then reverts back to PS>. This tells me that oh-my-posh is correctly installed, and the omp file is also correctly configured.

All the other windows terminal settings from PC #1 have been backed up and copied across to PC # 2 too.

What other settings might I have missed to prevent the oh-my-posh path from being displayed?


UPDATE (debugging info)

Following the debugging information from @mklement0 below the following errors occurred: enter image description here

Can anyone provide any information on these?


Solution

  • Note:


    Examining (the most) recent error(s):

    As Jan De Dobbeleer points out, it may be sufficient to simply examine what error(s) occurred when the prompt function last executed, via the automatic $Error variable, which records all errors that occur in a session:

    To examine the details of the error(s) that occurred:

    Note:

    Debugging the prompt PowerShell function:

    Here's a screenshot demonstrating such a session:

    function-debugging screenshot