JanDeDobbeleer / oh-my-posh

The most customisable and low-latency cross platform/shell prompt renderer
https://ohmyposh.dev
MIT License
17.02k stars 2.37k forks source link

Error reading template from transient_prompt #2794

Closed pcostarg closed 2 years ago

pcostarg commented 2 years ago

Code of Conduct

What happened?

The issue started to happen after installing oh my posh on a new machine with latest version: 9.2.0:

image

Old machine with version works fine with version 6.2.0:

image

Theme

I'm using a custom theme made by me sometime ago.

The theme is as follows:

{
  "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
  "blocks": [
    {
      "alignment": "left",
      "segments": [
        {
          "background": "#c386f1",
          "foreground": "#ffffff",
          "leading_diamond": "\ue0b6",
          "properties": {
            "display_host": false
          },
          "style": "diamond",
          "template": " {{ if .SSHSession }}\uf817 {{ end }}{{ .UserName }} ",
          "type": "session"
        },
        {
          "background": "#ffff66",
          "foreground": "#193549",
          "powerline_symbol": "\ue0b0",
          "style": "powerline",
          "template": " \uf0e7 ",
          "type": "root"
        },
        {
          "background": "#0077c2",
          "foreground": "#ffffff",
          "powerline_symbol": "\ue0b0",
          "style": "powerline",
          "template": " \uf489 {{ .Name }}",
          "type": "shell"
        },
        {
          "background": "#ff479c",
          "foreground": "#ffffff",
          "powerline_symbol": "\ue0b0",
          "properties": {
            "style": "agnoster"
          },
          "style": "powerline",
          "template": " \ue5ff {{ .Path }} ",
          "type": "path"
        },
        {
          "background": "#fffb38",
          "foreground": "#193549",
          "powerline_symbol": "\ue0b0",
          "properties": {
            "fetch_stash_count": true,
            "fetch_status": true,
            "fetch_upstream_icon": true
          },
          "style": "powerline",
          "template": " {{ .HEAD }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if and (.Staging.Changed) (.Working.Changed) }} |{{ end }}{{ if .Staging.Changed }} \uf046 {{ .Staging.String }}{{ end }}{{ if gt .StashCount 0}} \uf692 {{ .StashCount }}{{ end }}{{ if gt .WorktreeCount 0}} \uf1bb {{ .WorktreeCount }}{{ end }} ",
          "type": "git"
        },
        {
          "background": "#6CA35E",
          "foreground": "#ffffff",
          "powerline_symbol": "\ue0b0",
          "properties": {
            "fetch_version": true
          },
          "style": "powerline",
          "template": " \ue70c {{ if .Unsupported }}\uf071{{ else }}{{ .Full }}{{ end }} ",
          "type": "dotnet"
        },
        {
          "background": "#2e9599",
          "background_templates": [
            "{{ if gt .Code 0 }}#f1184c{{ end }}"
          ],
          "foreground": "#ffffff",
          "powerline_symbol": "\ue0b0",
          "properties": {
            "always_enabled": true
          },
          "style": "powerline",
          "template": " \ue23a{{ if gt .Code 0 }}\uf00d{{ else }}\uf42e{{ end }} ",
          "trailing_diamond": "\ue0b4",
          "type": "exit"
        }
      ],
      "type": "prompt"
    },
    {
      "alignment": "right",
      "segments": [
        {
          "background": "#1BD760",
          "foreground": "#111111",
          "invert_powerline": true,
          "powerline_symbol": "\ue0b2",
          "properties": {
            "paused_icon": "\uf04c ",
            "playing_icon": "\uf04b "
          },
          "style": "powerline",
          "template": " \uf167 {{ .Icon }}{{ if ne .Status \"stopped\" }}{{ .Artist }} - {{ .Track }}{{ end }} ",
          "type": "ytm"
        },
        {
          "background": "#2e9599",
          "foreground": "#111111",
          "invert_powerline": true,
          "leading_diamond": "\ue0b2",
          "style": "powerline",
          "template": " {{ .CurrentDate | date .Format }} ",
          "trailing_diamond": "\ue0b4",
          "type": "time"
        }
      ],
      "type": "prompt"
    },
    {
      "alignment": "left",
      "newline": true,
      "segments": [
        {
          "foreground": "#007ACC",
          "style": "plain",
          "template": "\ue602 ",
          "type": "text"
        }
      ],
      "type": "prompt"
    }
  ],
  "osc99": true,
  "transient_prompt": {
    "background": "transparent",
    "foreground": "#ffffff",
    "template": "<[{{ .now | date \"02-01 15:04\" }}]{{ .Shell}}> {{ .Path }}> "
  },
  "version": 2
}

What OS are you seeing the problem on?

Windows

Which shell are you using?

powershell

Log output

Version: 9.2.0

Segments:

ConsoleTitle(false) -   0 ms -
session(true)  -   1 ms -  ****
root(true)     -   0 ms -  
shell(true)    -   0 ms -   pwsh
path(true)     -   0 ms -   C:\Work
git(false)     -   2 ms -
dotnet(false)  -   0 ms -
exit(true)     -   2 ms -  
ytm(false)     -  31 ms -
time(true)     -   0 ms -  17:38:38
text(true)     -   0 ms - 

Run duration: 50.7684ms

Cache path: %LocalAppData%\oh-my-posh

Config path: %LocalAppData%\Programs\oh-my-posh\themes\_ohmyposh-v1.omp.json

Logs:

2022/09/15 17:38:38 debug: Getenv
%LocalAppData%
2022/09/15 17:38:38 Getenv duration: 0s, args: LOCALAPPDATA
2022/09/15 17:38:38 CachePath duration: 0s, args:
2022/09/15 17:38:38 debug: Getenv
%LocalAppData%\Programs\oh-my-posh\themes\_ohmyposh-v1.omp.json
2022/09/15 17:38:38 Getenv duration: 0s, args: POSH_THEME
2022/09/15 17:38:38 Shell duration: 11.7502ms, args:
2022/09/15 17:38:38 resolveConfigPath duration: 11.7502ms, args:
2022/09/15 17:38:38 Init duration: 12.4083ms, args:
2022/09/15 17:38:38 Flags duration: 0s, args:
2022/09/15 17:38:38 config.loadConfig duration: 1.0008ms, args:
2022/09/15 17:38:38 Flags duration: 0s, args:
2022/09/15 17:38:38 debug: Getenv

2022/09/15 17:38:38 Getenv duration: 0s, args: OMP_CACHE_DISABLED
2022/09/15 17:38:38 WindowsRegistryKeyValue duration: 0s, args: HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM\ColorizationColor
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 debug: WindowsRegistryKeyValue
ColorizationColor(DWORD): 0xC40078D4
2022/09/15 17:38:38 Root duration: 0s, args:
2022/09/15 17:38:38 Shell duration: 0s, args:
2022/09/15 17:38:38 ErrorCode duration: 0s, args:
2022/09/15 17:38:38 IsWsl duration: 0s, args:
2022/09/15 17:38:38 debug: Pwd
C:\Work
2022/09/15 17:38:38 Pwd duration: 0s, args:
2022/09/15 17:38:38 debug: Home
C:\Users\****
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 debug: User
****
2022/09/15 17:38:38 User duration: 0s, args:
2022/09/15 17:38:38 debug: Host
MSI
2022/09/15 17:38:38 Host duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 TemplateCache duration: 0s, args:
2022/09/15 17:38:38 Flags duration: 0s, args:
2022/09/15 17:38:38 debug: Pwd
C:\Work
2022/09/15 17:38:38 Pwd duration: 0s, args:
2022/09/15 17:38:38 debug: Home
C:\Users\****
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 debug: Getenv

2022/09/15 17:38:38 Getenv duration: 0s, args: SSH_CONNECTION
2022/09/15 17:38:38 debug: Getenv

2022/09/15 17:38:38 Getenv duration: 0s, args: SSH_CLIENT
2022/09/15 17:38:38 TemplateCache duration: 0s, args:
2022/09/15 17:38:38 TemplateCache duration: 0s, args:
2022/09/15 17:38:38 Shell duration: 0s, args:
2022/09/15 17:38:38 debug: Pwd
C:\Work
2022/09/15 17:38:38 Pwd duration: 0s, args:
2022/09/15 17:38:38 debug: Home
C:\Users\****
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 Root duration: 0s, args:
2022/09/15 17:38:38 TemplateCache duration: 0s, args:
2022/09/15 17:38:38 TemplateCache duration: 0s, args:
2022/09/15 17:38:38 Shell duration: 0s, args:
2022/09/15 17:38:38 debug: Pwd
C:\Work
2022/09/15 17:38:38 Pwd duration: 0s, args:
2022/09/15 17:38:38 debug: Home
C:\Users\****
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 Shell duration: 0s, args:
2022/09/15 17:38:38 Flags duration: 0s, args:
2022/09/15 17:38:38 TemplateCache duration: 0s, args:
2022/09/15 17:38:38 TemplateCache duration: 0s, args:
2022/09/15 17:38:38 Shell duration: 0s, args:
2022/09/15 17:38:38 debug: Pwd
C:\Work
2022/09/15 17:38:38 Pwd duration: 0s, args:
2022/09/15 17:38:38 debug: Home
C:\Users\****
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 debug: Pwd
C:\Work
2022/09/15 17:38:38 Pwd duration: 0s, args:
2022/09/15 17:38:38 Flags duration: 0s, args:
2022/09/15 17:38:38 debug: Pwd
C:\Work
2022/09/15 17:38:38 Pwd duration: 0s, args:
2022/09/15 17:38:38 debug: Home
C:\Users\****
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 Flags duration: 0s, args:
2022/09/15 17:38:38 debug: Pwd
C:\Work
2022/09/15 17:38:38 Pwd duration: 0s, args:
2022/09/15 17:38:38 debug: Home
C:\Users\****
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 PathSeparator duration: 0s, args:
2022/09/15 17:38:38 PathSeparator duration: 0s, args:
2022/09/15 17:38:38 PathSeparator duration: 0s, args:
2022/09/15 17:38:38 PathSeparator duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 IsWsl duration: 0s, args:
2022/09/15 17:38:38 StackCount duration: 0s, args:
2022/09/15 17:38:38 DirIsWritable duration: 0s, args:
2022/09/15 17:38:38 TemplateCache duration: 0s, args:
2022/09/15 17:38:38 TemplateCache duration: 0s, args:
2022/09/15 17:38:38 Shell duration: 0s, args:
2022/09/15 17:38:38 debug: Pwd
C:\Work
2022/09/15 17:38:38 Pwd duration: 0s, args:
2022/09/15 17:38:38 debug: Home
C:\Users\****
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 debug: CommandPath
C:\Program Files\Git\cmd\git.exe
2022/09/15 17:38:38 CommandPath duration: 2.9986ms, args: git.exe
2022/09/15 17:38:38 HasCommand duration: 2.9986ms, args: git.exe
2022/09/15 17:38:38 debug: Pwd
C:\Work
2022/09/15 17:38:38 Pwd duration: 0s, args:
2022/09/15 17:38:38 error: HasParentFilePath
CreateFile C:\.git: The system cannot find the file specified.
2022/09/15 17:38:38 HasParentFilePath duration: 0s, args: .git
2022/09/15 17:38:38 debug: Pwd
C:\Work
2022/09/15 17:38:38 Pwd duration: 0s, args:
2022/09/15 17:38:38 debug: Home
C:\Users\****
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 debug: Pwd
C:\Work
2022/09/15 17:38:38 Pwd duration: 0s, args:
2022/09/15 17:38:38 debug: Home
C:\Users\****
2022/09/15 17:38:38 debug: Pwd
C:\Work
2022/09/15 17:38:38 Pwd duration: 0s, args:
2022/09/15 17:38:38 PathSeparator duration: 0s, args:
2022/09/15 17:38:38 debug: HasFiles
false
2022/09/15 17:38:38 HasFiles duration: 0s, args: *.cs
2022/09/15 17:38:38 debug: Pwd
C:\Work
2022/09/15 17:38:38 Pwd duration: 0s, args:
2022/09/15 17:38:38 PathSeparator duration: 0s, args:
2022/09/15 17:38:38 debug: HasFiles
false
2022/09/15 17:38:38 HasFiles duration: 0s, args: *.csx
2022/09/15 17:38:38 debug: Pwd
C:\Work
2022/09/15 17:38:38 Pwd duration: 0s, args:
2022/09/15 17:38:38 PathSeparator duration: 0s, args:
2022/09/15 17:38:38 debug: HasFiles
false
2022/09/15 17:38:38 HasFiles duration: 0s, args: *.vb
2022/09/15 17:38:38 debug: Pwd
C:\Work
2022/09/15 17:38:38 Pwd duration: 0s, args:
2022/09/15 17:38:38 PathSeparator duration: 0s, args:
2022/09/15 17:38:38 debug: HasFiles
false
2022/09/15 17:38:38 HasFiles duration: 0s, args: *.sln
2022/09/15 17:38:38 debug: Pwd
C:\Work
2022/09/15 17:38:38 Pwd duration: 0s, args:
2022/09/15 17:38:38 PathSeparator duration: 0s, args:
2022/09/15 17:38:38 debug: HasFiles
false
2022/09/15 17:38:38 HasFiles duration: 0s, args: *.slnf
2022/09/15 17:38:38 debug: Pwd
C:\Work
2022/09/15 17:38:38 Pwd duration: 0s, args:
2022/09/15 17:38:38 PathSeparator duration: 0s, args:
2022/09/15 17:38:38 debug: HasFiles
false
2022/09/15 17:38:38 HasFiles duration: 0s, args: *.csproj
2022/09/15 17:38:38 debug: Pwd
C:\Work
2022/09/15 17:38:38 Pwd duration: 0s, args:
2022/09/15 17:38:38 PathSeparator duration: 0s, args:
2022/09/15 17:38:38 debug: HasFiles
false
2022/09/15 17:38:38 HasFiles duration: 0s, args: *.vbproj
2022/09/15 17:38:38 debug: Pwd
C:\Work
2022/09/15 17:38:38 Pwd duration: 0s, args:
2022/09/15 17:38:38 PathSeparator duration: 0s, args:
2022/09/15 17:38:38 debug: HasFiles
false
2022/09/15 17:38:38 HasFiles duration: 0s, args: *.fs
2022/09/15 17:38:38 debug: Pwd
C:\Work
2022/09/15 17:38:38 Pwd duration: 0s, args:
2022/09/15 17:38:38 PathSeparator duration: 0s, args:
2022/09/15 17:38:38 debug: HasFiles
false
2022/09/15 17:38:38 HasFiles duration: 0s, args: *.fsx
2022/09/15 17:38:38 debug: Pwd
C:\Work
2022/09/15 17:38:38 Pwd duration: 0s, args:
2022/09/15 17:38:38 PathSeparator duration: 0s, args:
2022/09/15 17:38:38 debug: HasFiles
false
2022/09/15 17:38:38 HasFiles duration: 0s, args: *.fsproj
2022/09/15 17:38:38 debug: Pwd
C:\Work
2022/09/15 17:38:38 Pwd duration: 0s, args:
2022/09/15 17:38:38 PathSeparator duration: 0s, args:
2022/09/15 17:38:38 debug: HasFiles
false
2022/09/15 17:38:38 HasFiles duration: 0s, args: global.json
2022/09/15 17:38:38 debug: Pwd
C:\Work
2022/09/15 17:38:38 Pwd duration: 0s, args:
2022/09/15 17:38:38 debug: Home
C:\Users\****
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 ErrorCode duration: 0s, args:
2022/09/15 17:38:38 TemplateCache duration: 0s, args:
2022/09/15 17:38:38 TemplateCache duration: 0s, args:
2022/09/15 17:38:38 Shell duration: 0s, args:
2022/09/15 17:38:38 TemplateCache duration: 0s, args:
2022/09/15 17:38:38 Flags duration: 0s, args:
2022/09/15 17:38:38 debug: Pwd
C:\Work
2022/09/15 17:38:38 Pwd duration: 0s, args:
2022/09/15 17:38:38 debug: Home
C:\Users\****
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 debug: HTTPRequest
GET /query HTTP/1.1
Host: 127.0.0.1:9863
User-Agent: Go-http-client/1.1
Accept-Encoding: gzip

2022/09/15 17:38:38 error: HTTPRequest
Get "http://127.0.0.1:9863/query": context deadline exceeded
2022/09/15 17:38:38 HTTPRequest duration: 31.1131ms, args: http://127.0.0.1:9863/query
2022/09/15 17:38:38 debug: Pwd
C:\Work
2022/09/15 17:38:38 Pwd duration: 0s, args:
2022/09/15 17:38:38 debug: Home
C:\Users\****
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 TemplateCache duration: 0s, args:
2022/09/15 17:38:38 TemplateCache duration: 0s, args:
2022/09/15 17:38:38 Shell duration: 0s, args:
2022/09/15 17:38:38 Flags duration: 0s, args:
2022/09/15 17:38:38 debug: Pwd
C:\Work
2022/09/15 17:38:38 Pwd duration: 0s, args:
2022/09/15 17:38:38 debug: Home
C:\Users\****
2022/09/15 17:38:38 GOOS duration: 0s, args:
2022/09/15 17:38:38 TemplateCache duration: 0s, args:
2022/09/15 17:38:38 TemplateCache duration: 0s, args:
2022/09/15 17:38:38 Shell duration: 0s, args:
2022/09/15 17:38:38 debug: Getenv
%LocalAppData%
2022/09/15 17:38:38 Getenv duration: 0s, args: LOCALAPPDATA
2022/09/15 17:38:38 CachePath duration: 0s, args:
2022/09/15 17:38:38 Flags duration: 0s, args:
pcostarg commented 2 years ago

Also I would like to add that if I grab a template that works somewhere else like {{ .Path }}, it does not work in transient_prompt, but others like {{ .Shell }} work.

JanDeDobbeleer commented 2 years ago

There are two issues here. First of all .now doesn't work as it should be now. Secondly, .Path was replaced with .PWD in v6.46.0 which arguably should've been breaking change. The following template checks out:

"template": "<[{{ now | date \"02-01 15:04\" }}]{{ .Shell }}> {{ .PWD }}> "
github-actions[bot] commented 9 months ago

This issue has been automatically locked since there has not been any recent activity (i.e. last half year) after it was closed. It helps our maintainers focus on the active issues. If you have found a problem that seems similar, please open a discussion first, complete the body with all the details necessary to reproduce, and mention this issue as reference.