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

Az segment 'template' property '.Name' shows error 'unable to create text based on template' #1584

Closed Marc013 closed 2 years ago

Marc013 commented 2 years ago

Code of Conduct

What happened?

After updating oh-my-posh to version 6.48.0 the name of the subscription is no longer displayed. Instead error unable to create text based on template is shown. This applies to pwsh and Azure CLI

image

image

Theme

I'm using my own custom theme. Az segment I defined:

        {
          "type": "az",
          "style": "diamond",
          "powerline_symbol": "\uE0B0",
          "foreground": "#000000",
          "background": "#0674fa",
          "trailing_diamond": "",
          "properties": {
            "template": "{{ .Name }}",
            "prefix": " ﴃ "
          }
        },
        {
          "type": "az",
          "style": "diamond",
          "powerline_symbol": "\uE0B0",
          "foreground": "#000000",
          "background": "#0674fa",
          "trailing_diamond": "\uE0B0",
          "properties": {
            "template": "{{ .Origin }}"
          }
        },

What OS are you seeing the problem on?

Windows

Which shell are you using?

powershell

Log output

Write-PoshDebug

Version: 6.48.0

Segments:

ConsoleTitle(false) -   0 ms -
root(false)   -   0 ms -
exit(true)    -   0 ms - 
az(true)      -   0 ms -  ﴃ unable to create text based on template
az(true)      -   0 ms -  CLI 
path(true)    -   0 ms -  C:\ 
git(false)    -   5 ms -
python(false) -   0 ms -
exit(true)    -   0 ms - ❯

Run duration: 8.5042ms

Logs:

2022/01/15 12:51:42 debug: getenv
C:\Users\Marc********\AppData\Local
2022/01/15 12:51:42 getenv duration: 202.8µs, args: LOCALAPPDATA
2022/01/15 12:51:42 getCachePath duration: 513µs, args:
2022/01/15 12:51:42 getArgs duration: 0s, args:
2022/01/15 12:51:42 getArgs duration: 0s, args:
2022/01/15 12:51:42 getShellName duration: 0s, args:
2022/01/15 12:51:42 debug: getenv

2022/01/15 12:51:42 getenv duration: 0s, args: OMP_CACHE_DISABLED
2022/01/15 12:51:42 isRunningAsRoot duration: 502.2µs, args:
2022/01/15 12:51:42 getcwd duration: 0s, args:
2022/01/15 12:51:42 getPathSeperator duration: 0s, args:
2022/01/15 12:51:42 getPathSeperator duration: 0s, args:
2022/01/15 12:51:42 getShellName duration: 0s, args:
2022/01/15 12:51:42 getCurrentUser duration: 0s, args:
2022/01/15 12:51:42 getHostName duration: 0s, args:
2022/01/15 12:51:42 lastErrorCode duration: 0s, args:
2022/01/15 12:51:42 getcwd duration: 0s, args:
2022/01/15 12:51:42 isRunningAsRoot duration: 0s, args:
2022/01/15 12:51:42 getcwd duration: 0s, args:
2022/01/15 12:51:42 lastErrorCode duration: 0s, args:
2022/01/15 12:51:42 lastErrorCode duration: 0s, args:
2022/01/15 12:51:42 getcwd duration: 0s, args:
2022/01/15 12:51:42 getFileContent duration: 504.1µs, args: C:\Users\Marc********\.azure\azureProfile.json
2022/01/15 12:51:42 isRunningAsRoot duration: 0s, args:
2022/01/15 12:51:42 getcwd duration: 0s, args:
2022/01/15 12:51:42 getPathSeperator duration: 0s, args:
2022/01/15 12:51:42 getPathSeperator duration: 0s, args:
2022/01/15 12:51:42 getShellName duration: 0s, args:
2022/01/15 12:51:42 getCurrentUser duration: 0s, args:
2022/01/15 12:51:42 getHostName duration: 0s, args:
2022/01/15 12:51:42 lastErrorCode duration: 0s, args:
2022/01/15 12:51:42 getcwd duration: 0s, args:
2022/01/15 12:51:42 getFileContent duration: 508.3µs, args: C:\Users\Marc********\.azure\azureProfile.json
2022/01/15 12:51:42 isRunningAsRoot duration: 0s, args:
2022/01/15 12:51:42 getcwd duration: 0s, args:
2022/01/15 12:51:42 getPathSeperator duration: 0s, args:
2022/01/15 12:51:42 getPathSeperator duration: 0s, args:
2022/01/15 12:51:42 getShellName duration: 0s, args:
2022/01/15 12:51:42 getCurrentUser duration: 0s, args:
2022/01/15 12:51:42 getHostName duration: 510.7µs, args:
2022/01/15 12:51:42 lastErrorCode duration: 0s, args:
2022/01/15 12:51:42 getcwd duration: 0s, args:
2022/01/15 12:51:42 getcwd duration: 0s, args:
2022/01/15 12:51:42 getArgs duration: 0s, args:
2022/01/15 12:51:42 getRuntimeGOOS duration: 0s, args:
2022/01/15 12:51:42 getRuntimeGOOS duration: 0s, args:
2022/01/15 12:51:42 getPathSeperator duration: 0s, args:
2022/01/15 12:51:42 getPathSeperator duration: 0s, args:
2022/01/15 12:51:42 getPathSeperator duration: 0s, args:
2022/01/15 12:51:42 getRuntimeGOOS duration: 0s, args:
2022/01/15 12:51:42 stackCount duration: 0s, args:
2022/01/15 12:51:42 isRunningAsRoot duration: 0s, args:
2022/01/15 12:51:42 getcwd duration: 0s, args:
2022/01/15 12:51:42 getPathSeperator duration: 0s, args:
2022/01/15 12:51:42 getPathSeperator duration: 0s, args:
2022/01/15 12:51:42 getShellName duration: 0s, args:
2022/01/15 12:51:42 getCurrentUser duration: 0s, args:
2022/01/15 12:51:42 getHostName duration: 0s, args:
2022/01/15 12:51:42 lastErrorCode duration: 0s, args:
2022/01/15 12:51:42 getcwd duration: 0s, args:
2022/01/15 12:51:42 getRuntimeGOOS duration: 0s, args:
2022/01/15 12:51:42 hasCommand duration: 4.8424ms, args: git.exe
2022/01/15 12:51:42 getcwd duration: 0s, args:
2022/01/15 12:51:42 error: hasParentFilePath
CreateFile C:\.git: The system cannot find the file specified.
2022/01/15 12:51:42 hasParentFilePath duration: 488.9µs, args: .git
2022/01/15 12:51:42 getcwd duration: 0s, args:
2022/01/15 12:51:42 getcwd duration: 0s, args:
2022/01/15 12:51:42 debug: getenv

2022/01/15 12:51:42 getenv duration: 0s, args: VIRTUAL_ENV
2022/01/15 12:51:42 debug: getenv

2022/01/15 12:51:42 getenv duration: 0s, args: CONDA_ENV_PATH
2022/01/15 12:51:42 debug: getenv

2022/01/15 12:51:42 getenv duration: 0s, args: CONDA_DEFAULT_ENV
2022/01/15 12:51:42 debug: getenv

2022/01/15 12:51:42 getenv duration: 0s, args: PYENV_VERSION
2022/01/15 12:51:42 getcwd duration: 0s, args:
2022/01/15 12:51:42 lastErrorCode duration: 0s, args:

========================

$OhMyPoshConfig = "C:\Users\Marc********\OneDrive - ********\Documents\PowerShell\Theme\marc013.omp.json"

oh-my-posh --debug --shell uni --config="$OhMyPoshConfig"

Version: 6.48.0

Segments:

ConsoleTitle(false) -   0 ms -
root(false)   -   0 ms -
exit(false)   -   0 ms -
az(true)      -   0 ms -  ﴃ unable to create text based on template
az(true)      -   0 ms -  CLI 
path(true)    -   0 ms -  C:\ 
git(false)    -   7 ms -
python(false) -   1 ms -
exit(true)    -   0 ms - ❯

Run duration: 12.6094ms

Logs:

2022/01/15 12:49:07 debug: getenv
C:\Users\Marc********\AppData\Local
2022/01/15 12:49:07 getenv duration: 0s, args: LOCALAPPDATA
2022/01/15 12:49:07 getCachePath duration: 501.4µs, args:
2022/01/15 12:49:07 getArgs duration: 0s, args:
2022/01/15 12:49:07 getArgs duration: 0s, args:
2022/01/15 12:49:07 getShellName duration: 0s, args:
2022/01/15 12:49:07 debug: getenv

2022/01/15 12:49:07 getenv duration: 0s, args: OMP_CACHE_DISABLED
2022/01/15 12:49:07 isRunningAsRoot duration: 0s, args:
2022/01/15 12:49:07 getcwd duration: 0s, args:
2022/01/15 12:49:07 getPathSeperator duration: 0s, args:
2022/01/15 12:49:07 getPathSeperator duration: 0s, args:
2022/01/15 12:49:07 getShellName duration: 0s, args:
2022/01/15 12:49:07 getCurrentUser duration: 0s, args:
2022/01/15 12:49:07 getHostName duration: 0s, args:
2022/01/15 12:49:07 lastErrorCode duration: 0s, args:
2022/01/15 12:49:07 getcwd duration: 0s, args:
2022/01/15 12:49:07 isRunningAsRoot duration: 0s, args:
2022/01/15 12:49:07 getcwd duration: 0s, args:
2022/01/15 12:49:07 lastErrorCode duration: 0s, args:
2022/01/15 12:49:07 getcwd duration: 0s, args:
2022/01/15 12:49:07 getFileContent duration: 501.7µs, args: C:\Users\Marc********\.azure\azureProfile.json
2022/01/15 12:49:07 isRunningAsRoot duration: 0s, args:
2022/01/15 12:49:07 getcwd duration: 0s, args:
2022/01/15 12:49:07 getPathSeperator duration: 0s, args:
2022/01/15 12:49:07 getPathSeperator duration: 0s, args:
2022/01/15 12:49:07 getShellName duration: 0s, args:
2022/01/15 12:49:07 getCurrentUser duration: 0s, args:
2022/01/15 12:49:07 getHostName duration: 500µs, args:
2022/01/15 12:49:07 lastErrorCode duration: 0s, args:
2022/01/15 12:49:07 getcwd duration: 0s, args:
2022/01/15 12:49:07 getFileContent duration: 0s, args: C:\Users\Marc********\.azure\azureProfile.json
2022/01/15 12:49:07 isRunningAsRoot duration: 525.3µs, args:
2022/01/15 12:49:07 getcwd duration: 0s, args:
2022/01/15 12:49:07 getPathSeperator duration: 0s, args:
2022/01/15 12:49:07 getPathSeperator duration: 0s, args:
2022/01/15 12:49:07 getShellName duration: 0s, args:
2022/01/15 12:49:07 getCurrentUser duration: 0s, args:
2022/01/15 12:49:07 getHostName duration: 0s, args:
2022/01/15 12:49:07 lastErrorCode duration: 0s, args:
2022/01/15 12:49:07 getcwd duration: 0s, args:
2022/01/15 12:49:07 getcwd duration: 0s, args:
2022/01/15 12:49:07 getArgs duration: 0s, args:
2022/01/15 12:49:07 getcwd duration: 0s, args:
2022/01/15 12:49:07 getRuntimeGOOS duration: 0s, args:
2022/01/15 12:49:07 getRuntimeGOOS duration: 0s, args:
2022/01/15 12:49:07 getPathSeperator duration: 0s, args:
2022/01/15 12:49:07 getPathSeperator duration: 0s, args:
2022/01/15 12:49:07 getPathSeperator duration: 0s, args:
2022/01/15 12:49:07 getRuntimeGOOS duration: 0s, args:
2022/01/15 12:49:07 stackCount duration: 0s, args:
2022/01/15 12:49:07 isRunningAsRoot duration: 0s, args:
2022/01/15 12:49:07 getcwd duration: 0s, args:
2022/01/15 12:49:07 getPathSeperator duration: 0s, args:
2022/01/15 12:49:07 getPathSeperator duration: 0s, args:
2022/01/15 12:49:07 getShellName duration: 0s, args:
2022/01/15 12:49:07 getCurrentUser duration: 0s, args:
2022/01/15 12:49:07 getHostName duration: 0s, args:
2022/01/15 12:49:07 lastErrorCode duration: 0s, args:
2022/01/15 12:49:07 getcwd duration: 0s, args:
2022/01/15 12:49:07 getRuntimeGOOS duration: 0s, args:
2022/01/15 12:49:07 hasCommand duration: 7.4978ms, args: git.exe
2022/01/15 12:49:07 getcwd duration: 0s, args:
2022/01/15 12:49:07 error: hasParentFilePath
CreateFile C:\.git: The system cannot find the file specified.
2022/01/15 12:49:07 hasParentFilePath duration: 0s, args: .git
2022/01/15 12:49:07 getcwd duration: 0s, args:
2022/01/15 12:49:07 getcwd duration: 0s, args:
2022/01/15 12:49:07 debug: getenv

2022/01/15 12:49:07 getenv duration: 0s, args: VIRTUAL_ENV
2022/01/15 12:49:07 debug: getenv

2022/01/15 12:49:07 getenv duration: 0s, args: CONDA_ENV_PATH
2022/01/15 12:49:07 debug: getenv

2022/01/15 12:49:07 getenv duration: 0s, args: CONDA_DEFAULT_ENV
2022/01/15 12:49:07 debug: getenv

2022/01/15 12:49:07 getenv duration: 0s, args: PYENV_VERSION
2022/01/15 12:49:07 getcwd duration: 0s, args:
2022/01/15 12:49:07 lastErrorCode duration: 0s, args:
JanDeDobbeleer commented 2 years ago

@Marc013 please change this to .UserName, breaking change.

Marc013 commented 2 years ago

@JanDeDobbeleer,

It's a pity you closed this issue as it's not solved. Property .Name was showing the name of the subscription not the name of the user (this is indeed .UserName).

I use property .Name as I have many subscriptions and want to make clear what subscription is currently active within the active context. It would be great if you fixed this issue.

Marc013 commented 2 years ago

Apologies, deeply ashamed I am 😳 I have a subscription which matches my user account very closely, hence my confusion. This issue is solved.

JanDeDobbeleer commented 2 years ago

@Marc013 I did notice an issue with the mapping so I'm fixing that. Will be a breaking change but a needed one.

github-actions[bot] commented 7 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.