JanDeDobbeleer / oh-my-posh

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

Oh My Posh config migrated to version 1 #1713

Closed FlavienMacquignon closed 2 years ago

FlavienMacquignon commented 2 years ago

Code of Conduct

What happened?

Sorry, this is not technically not a bug but creating a issue here seems to be your way of managing support.

I tried to use Oh My Posh on ZSH and Linux Manjaro but everytime i try to source my .zshrc Oh My Posh migrate my config to version 1 and breaking my configuration. Bellow is a sample output of my configuration Issue_ZSH

As you can see, the output works then the universal shell is selected (except for the WIFI module)

Theme

{ "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json", "final_space": false, "osc99": true, "console_title": true, "console_title_style": "template", "console_title_template": "{{ .Folder }}", "transient_prompt": { "background": "transparent", "foreground": "#FEF5ED", "template": "\ue285 " }, "blocks": [ { "type": "prompt", "alignment": "left", "newline": true, "segments": [ { "type": "os", "style": "diamond", "leading_diamond": "\uE0B2", "trailing_diamond": "<transparent,#FEF5ED>\uE0B2</>", "foreground": "#011627", "background": "#FEF5ED", "properties": { "postfix": "", "windows": "\uf871 ", "macos": "\uf179 ", "ubuntu": "\uf31b " } }, { "type": "shell", "style": "diamond", "leading_diamond": "\uE0B2", "trailing_diamond": "<transparent,#FEF5ED>\uE0B2</>", "foreground": "#011627", "background": "#FEF5ED", "properties": { "prefix": "\uf489 ", "postfix": "" } }, { "type": "sysinfo", "style": "diamond", "leading_diamond": "\uE0B2", "trailing_diamond": "", "foreground": "#ffffff", "background": "#516BEB", "properties": { "prefix": "\uf85a CPU: ", "postfix": "% | ", "template": "{{ round .PhysicalPercentUsed .Precision }}" } }, { "type": "sysinfo", "style": "diamond", "leading_diamond": "", "trailing_diamond": "<transparent,#516BEB>\uE0B2</>", "foreground": "#ffffff", "background": "#516BEB", "properties": { "prefix": "MEM: ", "postfix": "GB \uf85a ", "template": "{{ (div ((sub .PhysicalTotalMemory .PhysicalFreeMemory)|float64) 1000000000.0) }}/{{ (div .PhysicalTotalMemory 1000000000.0) }}" } }, { "type": "executiontime", "style": "diamond", "leading_diamond": "\uE0B2", "trailing_diamond": "\uE0B0", "foreground": "#d6deeb", "background": "#575656", "properties": { "threshold": 0, "style": "roundrock" } }, { "type": "owm", "style": "powerline", "powerline_symbol": "\uE0B0", "foreground": "#ffffff", "background": "#a7970c", "properties": { "apikey": "fREDACTED", "location": "REDACTED", "units": "metric", "enable_hyperlink": true, "http_timeout": 100, "cache_timeout": 10, "template": "{{.Weather}} ({{.Temperature}}{{.UnitIcon}})" } } ] }, { "type": "prompt", "alignment": "right", "newline": false, "segments": [ { "type": "battery", "style": "powerline", "powerline_symbol": "\uE0B0", "foreground": "#193549", "background": "#ffeb3b", "background_templates": [ "{{if eq \"Charging\" .State.String}}#40c4ff{{end}}", "{{if eq \"Discharging\" .State.String}}#ff5722{{end}}", "{{if eq \"Full\" .State.String}}#4caf50{{end}}" ], "properties": { "discharging_icon": "\uE231 ", "charging_icon": "\uE234 ", "charged_icon": "\uE22F ", "postfix": "\uF295 ", "template": "{{ if not .Error }}{{.Icon}}{{.Percentage}}{{ end }}" } }, { "type": "wifi", "style": "powerline", "background": "#8822ee", "foreground": "#222222", "background_templates": [ "{{ if (lt .Signal 60) }}#DDDD11{{ else if (lt .Signal 90) }}#DD6611{{ else }}#11CC11{{ end }}" ], "powerline_symbol": "\uE0B0", "properties": { "template": "\uFAA8 {{ .SSID }} {{ .Signal }}% {{ .ReceiveRate }}Mbps" } }, { "type": "git", "style": "diamond", "leading_diamond": "\uE0B2", "trailing_diamond": "\uE0B0", "foreground": "#011627", "background": "#17D7A0", "properties": { "branch_icon": "\ue725 ", "fetch_status": true, "fetch_stash_count": true, "fetch_worktree_count": true, "fetch_upstream_icon": true, "template": "{{ .UpstreamIcon }}{{ .HEAD }}{{ .BranchStatus }}{{ if .Working.Changed }} \uF044 {{ .Working.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Staging.Changed }} \uF046 {{ .Staging.String }}{{ end }}{{ if gt .StashCount 0 }} \uF692 {{ .StashCount }}{{ end }}" } } ] }, { "type": "prompt", "alignment": "left", "newline": true, "segments": [ { "type": "text", "style": "plain", "properties": { "prefix": "", "postfix": "", "text": "╭─" } }, { "type": "time", "style": "plain", "properties": { "prefix": " \u2665 ", "postfix": " |", "time_format": "15:04" } }, { "type": "root", "style": "plain", "properties": { "root_icon": "\uf292 " } }, { "type": "path", "style": "plain", "properties": { "folder_separator_icon": " \uf554 ", "home_icon": "\uf7db ", "folder_icon": "\uf07b ", "style": "agnoster_full", "enable_hyperlink": true } } ] }, { "type": "prompt", "alignment": "left", "newline": true, "segments": [ { "type": "exit", "style": "plain", "properties": { "prefix": "", "template": "╰─", "always_enabled": true } } ] } ] }

What OS are you seeing the problem on?

Linux

Which shell are you using?

zsh

Log output

Version: 7.10.3

Segments:

ConsoleTitle(true)   -   0 ms - 
os(true)             -   0 ms -  
shell(true)          -   0 ms -  uni
sysinfo(true)        -  15 ms -  CPU: 29.43% | 
sysinfo(true)        -   1 ms - MEM: 5/7GB  
executiontime(true)  -   0 ms -  0ms 
owm(true)            -  86 ms -   (4.63°C) 
battery(true)        -   4 ms -  97 
wifi(false)          -   0 ms - 
git(false)           -   0 ms - 
text(true)           -   0 ms - ╭─
time(true)           -   0 ms -  ♥ 15:17 |
root(false)          -   0 ms - 
path(true)           -   0 ms -    
exit(true)           -   0 ms - ╰─ 

Run duration: 110.887914ms

Cache path: /home/flxibit/.cache/oh-my-posh

Logs:

2022/02/06 15:17:33 Args duration: 106ns, args: 
2022/02/06 15:17:33 Args duration: 45ns, args: 
2022/02/06 15:17:33 Args duration: 78ns, args: 
2022/02/06 15:17:33 Shell duration: 160ns, args: 
2022/02/06 15:17:33 debug: Getenv

2022/02/06 15:17:33 Getenv duration: 3.622µs, args: OMP_CACHE_DISABLED
2022/02/06 15:17:33 Root duration: 388ns, args: 
2022/02/06 15:17:33 Shell duration: 94ns, args: 
2022/02/06 15:17:33 ErrorCode duration: 61ns, args: 
2022/02/06 15:17:33 debug: Getenv

2022/02/06 15:17:33 Getenv duration: 2.531µs, args: WSL_DISTRO_NAME
2022/02/06 15:17:33 IsWsl duration: 4.299µs, args: 
2022/02/06 15:17:33 debug: Pwd
/home/flxibit
2022/02/06 15:17:33 Pwd duration: 13.63µs, args: 
2022/02/06 15:17:33 PathSeperator duration: 58ns, args: 
2022/02/06 15:17:33 PathSeperator duration: 32ns, args: 
2022/02/06 15:17:33 User duration: 178ns, args: 
2022/02/06 15:17:33 Host duration: 1.128µs, args: 
2022/02/06 15:17:33 GOOS duration: 54ns, args: 
2022/02/06 15:17:33 TemplateCache duration: 61.699µs, args: 
2022/02/06 15:17:33 debug: Pwd
/home/flxibit
2022/02/06 15:17:33 Pwd duration: 990ns, args: 
2022/02/06 15:17:33 GOOS duration: 51ns, args: 
2022/02/06 15:17:33 TemplateCache duration: 132ns, args: 
2022/02/06 15:17:33 debug: Pwd
/home/flxibit
2022/02/06 15:17:33 Pwd duration: 1.079µs, args: 
2022/02/06 15:17:33 Shell duration: 79ns, args: 
2022/02/06 15:17:33 TemplateCache duration: 109ns, args: 
2022/02/06 15:17:33 debug: Pwd
/home/flxibit
2022/02/06 15:17:33 Pwd duration: 10.655µs, args: 
2022/02/06 15:17:33 TemplateCache duration: 368ns, args: 
2022/02/06 15:17:33 debug: Pwd
/home/flxibit
2022/02/06 15:17:33 Pwd duration: 4.154µs, args: 
2022/02/06 15:17:33 TemplateCache duration: 263ns, args: 
2022/02/06 15:17:33 debug: Pwd
/home/flxibit
2022/02/06 15:17:33 Pwd duration: 2.553µs, args: 
2022/02/06 15:17:33 ExecutionTime duration: 799ns, args: 
2022/02/06 15:17:33 TemplateCache duration: 233ns, args: 
2022/02/06 15:17:33 debug: Pwd
/home/flxibit
2022/02/06 15:17:33 Pwd duration: 2.423µs, args: 
2022/02/06 15:17:33 HTTPRequest duration: 85.742015ms, args: http://api.openweathermap.org/data/2.5/weather?q=Clermont-Ferrand,FR&units=metric&appid=fc75dd7245d5745ef9fca3f7d2725d20
2022/02/06 15:17:33 TemplateCache duration: 728ns, args: 
2022/02/06 15:17:33 debug: Pwd
/home/flxibit
2022/02/06 15:17:33 Pwd duration: 8.106µs, args: 
2022/02/06 15:17:33 BatteryInfo duration: 1.034575ms, args: 
2022/02/06 15:17:33 TemplateCache duration: 393ns, args: 
2022/02/06 15:17:33 TemplateCache duration: 225ns, args: 
2022/02/06 15:17:33 TemplateCache duration: 129ns, args: 
2022/02/06 15:17:33 TemplateCache duration: 71ns, args: 
2022/02/06 15:17:33 TemplateCache duration: 89ns, args: 
2022/02/06 15:17:33 TemplateCache duration: 47ns, args: 
2022/02/06 15:17:33 TemplateCache duration: 52ns, args: 
2022/02/06 15:17:33 debug: Pwd
/home/flxibit
2022/02/06 15:17:33 Pwd duration: 1.029µs, args: 
2022/02/06 15:17:33 debug: Getenv

2022/02/06 15:17:33 Getenv duration: 930ns, args: WSL_DISTRO_NAME
2022/02/06 15:17:33 IsWsl duration: 2.633µs, args: 
2022/02/06 15:17:33 debug: Pwd
/home/flxibit
2022/02/06 15:17:33 Pwd duration: 620ns, args: 
2022/02/06 15:17:33 debug: Getenv

2022/02/06 15:17:33 Getenv duration: 705ns, args: WSL_DISTRO_NAME
2022/02/06 15:17:33 IsWsl duration: 1.945µs, args: 
2022/02/06 15:17:33 GOOS duration: 50ns, args: 
2022/02/06 15:17:33 HasCommand duration: 16.327µs, args: git
2022/02/06 15:17:33 debug: Pwd
/home/flxibit
2022/02/06 15:17:33 Pwd duration: 550ns, args: 
2022/02/06 15:17:33 error: HasParentFilePath
stat /.git: no such file or directory
2022/02/06 15:17:33 HasParentFilePath duration: 6.755µs, args: .git
2022/02/06 15:17:33 debug: Pwd
/home/flxibit
2022/02/06 15:17:33 Pwd duration: 574ns, args: 
2022/02/06 15:17:33 TemplateCache duration: 51ns, args: 
2022/02/06 15:17:33 debug: Pwd
/home/flxibit
2022/02/06 15:17:33 Pwd duration: 594ns, args: 
2022/02/06 15:17:33 TemplateCache duration: 55ns, args: 
2022/02/06 15:17:33 debug: Pwd
/home/flxibit
2022/02/06 15:17:33 Pwd duration: 669ns, args: 
2022/02/06 15:17:33 Root duration: 544ns, args: 
2022/02/06 15:17:33 debug: Pwd
/home/flxibit
2022/02/06 15:17:33 Pwd duration: 604ns, args: 
2022/02/06 15:17:33 debug: Pwd
/home/flxibit
2022/02/06 15:17:33 Pwd duration: 568ns, args: 
2022/02/06 15:17:33 Args duration: 46ns, args: 
2022/02/06 15:17:33 debug: Pwd
/home/flxibit
2022/02/06 15:17:33 Pwd duration: 481ns, args: 
2022/02/06 15:17:33 GOOS duration: 54ns, args: 
2022/02/06 15:17:33 GOOS duration: 35ns, args: 
2022/02/06 15:17:33 PathSeperator duration: 72ns, args: 
2022/02/06 15:17:33 PathSeperator duration: 34ns, args: 
2022/02/06 15:17:33 GOOS duration: 44ns, args: 
2022/02/06 15:17:33 debug: Getenv

2022/02/06 15:17:33 Getenv duration: 780ns, args: WSL_DISTRO_NAME
2022/02/06 15:17:33 IsWsl duration: 1.997µs, args: 
2022/02/06 15:17:33 StackCount duration: 94ns, args: 
2022/02/06 15:17:33 TemplateCache duration: 60ns, args: 
2022/02/06 15:17:33 debug: Pwd
/home/flxibit
2022/02/06 15:17:33 Pwd duration: 1.135µs, args: 
2022/02/06 15:17:33 ErrorCode duration: 293ns, args: 
2022/02/06 15:17:33 TemplateCache duration: 35ns, args: 
2022/02/06 15:17:33 debug: Getenv

2022/02/06 15:17:33 Getenv duration: 916ns, args: XDG_CACHE_HOME
2022/02/06 15:17:33 CachePath duration: 8.377µs, args:
JanDeDobbeleer commented 2 years ago

@FlavienMacquignon I don't right away understand why you prompt differs from the config you're displaying.

The fact the you see the strange characters is because the prompt (on zsh and bash) needs to be escaped. Which obviously looks weird when you run oh-my-posh like this. What does your .zshrc look like?

FlavienMacquignon commented 2 years ago

Here is my .zshrc

eval "$(oh-my-posh --init --shell zsh --config ~/clean-detailed2.omp.json)"
# Use powerline
USE_POWERLINE="true"
# Source manjaro-zsh-configuration
if [[ -e /usr/share/zsh/manjaro-zsh-config ]]; then
  source /usr/share/zsh/manjaro-zsh-config
fi
# Use manjaro zsh prompt
if [[ -e /usr/share/zsh/manjaro-zsh-prompt ]]; then
  source /usr/share/zsh/manjaro-zsh-prompt
fi
FlavienMacquignon commented 2 years ago

Just found out while testing that Oh My Posh generate a second configuration file then i tried to load mine and back-it up, here is the generated configuration:

{
  "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
  "blocks": [
    {
      "alignment": "left",
      "newline": true,
      "segments": [
        {
          "background": "#FEF5ED",
          "foreground": "#011627",
          "leading_diamond": "\ue0b2",
          "properties": {
            "macos": "\uf179 ",
            "template": " {{ if .WSL }}WSL at {{ end }}{{.Icon}}",
            "ubuntu": "\uf31b ",
            "windows": "\uf871 "
          },
          "style": "diamond",
          "trailing_diamond": "<transparent,#FEF5ED>\ue0b2</>",
          "type": "os"
        },
        {
          "background": "#FEF5ED",
          "foreground": "#011627",
          "leading_diamond": "\ue0b2",
          "properties": {
            "template": "\uf489 {{ .Name }}"
          },
          "style": "diamond",
          "trailing_diamond": "<transparent,#FEF5ED>\ue0b2</>",
          "type": "shell"
        },
        {
          "background": "#516BEB",
          "foreground": "#ffffff",
          "leading_diamond": "\ue0b2",
          "properties": {
            "template": "\uf85a CPU: {{ round .PhysicalPercentUsed .Precision }}% | "
          },
          "style": "diamond",
          "type": "sysinfo"
        },
        {
          "background": "#516BEB",
          "foreground": "#ffffff",
          "properties": {
            "template": "MEM: {{ (div ((sub .PhysicalTotalMemory .PhysicalFreeMemory)|float64) 1000000000.0) }}/{{ (div .PhysicalTotalMemory 1000000000.0) }}GB \uf85a "
          },
          "style": "diamond",
          "trailing_diamond": "<transparent,#516BEB>\ue0b2</>",
          "type": "sysinfo"
        },
        {
          "background": "#575656",
          "foreground": "#d6deeb",
          "leading_diamond": "\ue0b2",
          "properties": {
            "style": "roundrock",
            "template": " {{ .FormattedMs }} ",
            "threshold": 0
          },
          "style": "diamond",
          "trailing_diamond": "\ue0b0",
          "type": "executiontime"
        },
        {
          "background": "#a7970c",
          "foreground": "#ffffff",
          "powerline_symbol": "\ue0b0",
          "properties": {
            "apikey": "REDACTED",
            "cache_timeout": 10,
            "http_timeout": 100,
            "location": "REDACTED",
            "template": " {{.Weather}} ({{.Temperature}}{{.UnitIcon}}) ",
            "units": "metric"
          },
          "style": "powerline",
          "type": "owm"
        }
      ],
      "type": "prompt"
    },
    {
      "alignment": "right",
      "segments": [
        {
          "background": "#ffeb3b",
          "background_templates": [
            "{{if eq \"Charging\" .State.String}}#40c4ff{{end}}",
            "{{if eq \"Discharging\" .State.String}}#ff5722{{end}}",
            "{{if eq \"Full\" .State.String}}#4caf50{{end}}"
          ],
          "foreground": "#193549",
          "powerline_symbol": "\ue0b0",
          "properties": {
            "charged_icon": "\ue22f ",
            "charging_icon": "\ue234 ",
            "discharging_icon": "\ue231 ",
            "template": " {{ if not .Error }}{{.Icon}}{{.Percentage}}{{ end }}\uf295 "
          },
          "style": "powerline",
          "type": "battery"
        },
        {
          "background": "#8822ee",
          "background_templates": [
            "{{ if (lt .Signal 60) }}#DDDD11{{ else if (lt .Signal 90) }}#DD6611{{ else }}#11CC11{{ end }}"
          ],
          "foreground": "#222222",
          "powerline_symbol": "\ue0b0",
          "properties": {
            "template": " \ufaa8 {{ .SSID }} {{ .Signal }}% {{ .ReceiveRate }}Mbps "
          },
          "style": "powerline",
          "type": "wifi"
        },
        {
          "background": "#17D7A0",
          "foreground": "#011627",
          "leading_diamond": "\ue0b2",
          "properties": {
            "branch_icon": "\ue725 ",
            "fetch_stash_count": true,
            "fetch_status": true,
            "fetch_upstream_icon": true,
            "fetch_worktree_count": true,
            "template": " {{ .UpstreamIcon }}{{ .HEAD }}{{ .BranchStatus }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Staging.Changed }} \uf046 {{ .Staging.String }}{{ end }}{{ if gt .StashCount 0 }} \uf692 {{ .StashCount }}{{ end }} "
          },
          "style": "diamond",
          "trailing_diamond": "\ue0b0",
          "type": "git"
        }
      ],
      "type": "prompt"
    },
    {
      "alignment": "left",
      "newline": true,
      "segments": [
        {
          "properties": {
            "template": "\u256d\u2500"
          },
          "style": "plain",
          "type": "text"
        },
        {
          "properties": {
            "template": " \u2665 {{ .CurrentDate | date .Format }} |",
            "time_format": "15:04"
          },
          "style": "plain",
          "type": "time"
        },
        {
          "properties": {
            "root_icon": "\uf292 ",
            "template": " \uf0e7 "
          },
          "style": "plain",
          "type": "root"
        },
        {
          "properties": {
            "folder_icon": "\uf07b ",
            "folder_separator_icon": " \uf554 ",
            "home_icon": "\uf7db ",
            "style": "agnoster_full",
            "template": " {{ .Path }} "
          },
          "style": "plain",
          "type": "path"
        }
      ],
      "type": "prompt"
    },
    {
      "alignment": "left",
      "newline": true,
      "segments": [
        {
          "properties": {
            "always_enabled": true,
            "template": "\u2570\u2500 "
          },
          "style": "plain",
          "type": "exit"
        }
      ],
      "type": "prompt"
    }
  ],
  "console_title": true,
  "console_title_style": "template",
  "console_title_template": "{{ .Folder }}",
  "osc99": true,
  "transient_prompt": {
    "background": "transparent",
    "foreground": "#FEF5ED",
    "template": "\ue285 "
  },
  "version": 1
}
JanDeDobbeleer commented 2 years ago

I'm sorry but I'm having trouble understanding the issue, oh-my-posh needs to migrate the first config you posted to version 1, that's what the second config you posted looks like (and it overwrites the original, bug keeps a backup). So what are you trying to do as it looks correct from my pov?

FlavienMacquignon commented 2 years ago

Ok, so Adding the line : "version": 1, before the "blocks": [ line in my original config seems to have resolved my issue for the prompt, however, the WIFI block still don't work.

The issue seems related as the way Oh My Posh handle configuration migration since the rewriting of the "new" configuration put the "version": 1 line at the end and this break the configuration

FlavienMacquignon commented 2 years ago

Ok, nevermind, the issue is on my part the default configuration for Manjaro Zsh is still Loaded even if I source Oh My Posh at the end of the .zshrc file. So it's more a PEBKAC than a real issue on Oh My Posh

JanDeDobbeleer commented 2 years ago

@FlavienMacquignon the wifi block only works on Windows for now (I think, need to double check).

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