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

Slow loading #4206

Closed prestonr83 closed 1 year ago

prestonr83 commented 1 year ago

Code of Conduct

What happened?

A bug happened! Its not detecting my shell setting and tries to detect it each run causing slowness.

Init settings

oh-my-posh init powershell --config ~/.mytheme.omp.json | Invoke-Expression

Theme

{
  "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
  "blocks": [
    {
      "alignment": "left",
      "segments": [
        {
          "background": "#0077c2",
          "foreground": "#ffffff",
          "leading_diamond": "\u256d\u2500\ue0b6",
          "style": "diamond",
          "template": "\uf120 {{ .Name }} ",
          "type": "shell"
        },
        {
          "background": "#ef5350",
          "foreground": "#FFFB38",
          "style": "diamond",
          "template": "<parentBackground>\ue0b0</> \uf292 ",
          "type": "root"
        },
        {
          "background": "#FF9248",
          "foreground": "#2d3436",
          "powerline_symbol": "\ue0b0",
          "properties": {
            "folder_icon": " \uf07b ",
            "home_icon": "\ue617",
            "style": "folder"
          },
          "style": "powerline",
          "template": " \uf07b\uea9c{{ .Path }} ",
          "type": "path"
        },
        {
          "background": "#FFFB38",
          "background_templates": [
            "{{ if or (.Working.Changed) (.Staging.Changed) }}#ffeb95{{ end }}",
            "{{ if and (gt .Ahead 0) (gt .Behind 0) }}#c5e478{{ end }}",
            "{{ if gt .Ahead 0 }}#C792EA{{ end }}",
            "{{ if gt .Behind 0 }}#C792EA{{ end }}"
          ],
          "foreground": "#011627",
          "powerline_symbol": "\ue0b0",
          "properties": {
            "branch_icon": "\ue725 ",
            "fetch_status": true,
            "fetch_upstream_icon": true
          },
          "style": "powerline",
          "template": " {{ .UpstreamIcon }}{{ .HEAD }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Staging.Changed }}<#ef5350> \uf046 {{ .Staging.String }}</>{{ end }} ",
          "type": "git"
        },
        {
          "background": "#83769c",
          "foreground": "#ffffff",
          "properties": {
            "style": "roundrock",
            "threshold": 0
          },
          "style": "diamond",
          "template": " \ueba2{{ .FormattedMs }}\u2800",
          "trailing_diamond": "\ue0b4",
          "type": "executiontime"
        }
      ],
      "type": "prompt"
    },
    {
      "alignment": "right",
      "segments": [
        {
          "background": "#303030",
          "foreground": "#3C873A",
          "leading_diamond": "\ue0b6",
          "properties": {
            "fetch_package_manager": true,
            "npm_icon": " <#cc3a3a>\ue5fa</> ",
            "yarn_icon": " <#348cba>\ue6a7</>"
          },
          "style": "diamond",
          "template": "\ue718 {{ if .PackageManagerIcon }}{{ .PackageManagerIcon }} {{ end }}{{ .Full }}",
          "trailing_diamond": "\ue0b4 ",
          "type": "node"
        },
        {
          "background": "#306998",
          "foreground": "#FFE873",
          "leading_diamond": "\ue0b6",
          "style": "diamond",
          "template": "\ue235 {{ if .Error }}{{ .Error }}{{ else }}{{ if .Venv }}{{ .Venv }} {{ end }}{{ .Full }}{{ end }}",
          "trailing_diamond": "\ue0b4 ",
          "type": "python"
        },
        {
          "background": "#0e8ac8",
          "foreground": "#ec2729",
          "leading_diamond": "\ue0b6",
          "style": "diamond",
          "template": "\ue738 {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}",
          "trailing_diamond": "\ue0b4 ",
          "type": "java"
        },
        {
          "background": "#0e0e0e",
          "foreground": "#0d6da8",
          "leading_diamond": "\ue0b6",
          "style": "diamond",
          "template": "\ue77f {{ if .Unsupported }}\uf071{{ else }}{{ .Full }}{{ end }}",
          "trailing_diamond": "\ue0b4 ",
          "type": "dotnet"
        },
        {
          "background": "#ffffff",
          "foreground": "#06aad5",
          "leading_diamond": "\ue0b6",
          "style": "diamond",
          "template": "\ue626 {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}",
          "trailing_diamond": "\ue0b4 ",
          "type": "go"
        },
        {
          "background": "#f3f0ec",
          "foreground": "#925837",
          "leading_diamond": "\ue0b6",
          "style": "diamond",
          "template": "\ue7a8 {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}",
          "trailing_diamond": "\ue0b4 ",
          "type": "rust"
        },
        {
          "background": "#e1e8e9",
          "foreground": "#055b9c",
          "leading_diamond": " \ue0b6",
          "style": "diamond",
          "template": "\ue798 {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}",
          "trailing_diamond": "\ue0b4 ",
          "type": "dart"
        },
        {
          "background": "#ffffff",
          "foreground": "#ce092f",
          "leading_diamond": " \ue0b6",
          "style": "diamond",
          "template": "\ue753 {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}",
          "trailing_diamond": "\ue0b4 ",
          "type": "angular"
        },
        {
          "background": "#1e293b",
          "foreground": "#ffffff",
          "leading_diamond": " \ue0b6",
          "style": "diamond",
          "template": "{{ if .Error }}{{ .Error }}{{ else }}Nx {{ .Full }}{{ end }}",
          "trailing_diamond": "\ue0b4 ",
          "type": "nx"
        },
        {
          "background": "#945bb3",
          "foreground": "#359a25",
          "leading_diamond": " \ue0b6",
          "style": "diamond",
          "template": "<#ca3c34>\ue624</> {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}",
          "trailing_diamond": "\ue0b4 ",
          "type": "julia"
        },
        {
          "background": "#ffffff",
          "foreground": "#9c1006",
          "leading_diamond": "\ue0b6",
          "style": "diamond",
          "template": "\ue791 {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}",
          "trailing_diamond": "\ue0b4 ",
          "type": "ruby"
        },
        {
          "background": "#ffffff",
          "foreground": "#5398c2",
          "leading_diamond": "\ue0b6",
          "style": "diamond",
          "template": "\uf104<#f5bf45>\uf0e7</>\uf105 {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}",
          "trailing_diamond": "\ue0b4 ",
          "type": "azfunc"
        },
        {
          "background": "#565656",
          "foreground": "#faa029",
          "leading_diamond": "\ue0b6",
          "style": "diamond",
          "template": "\ue7ad {{.Profile}}{{if .Region}}@{{.Region}}{{end}}",
          "trailing_diamond": "\ue0b4 ",
          "type": "aws"
        },
        {
          "background": "#316ce4",
          "foreground": "#ffffff",
          "leading_diamond": "\ue0b6",
          "style": "diamond",
          "template": "\uf308 {{.Context}}{{if .Namespace}} :: {{.Namespace}}{{end}}",
          "trailing_diamond": "\ue0b4",
          "type": "kubectl",
          "properties": {
            "parse_kubeconfig": true,
            "context_aliases": {
              "APIServicesDev": "DEV",
              "APIServicesInt": "INT",
              "APIServicesUAT": "UAT",
              "APIServicesProd-CUS": "PROD-CUS",
              "APIServicesProd-eus2": "PROD-EUS2"
            }
          }
        },
        {
          "background": "#b2bec3",
          "foreground": "#000000",
          "leading_diamond": "\ue0b6",
          "properties": {
            "source": "pwsh"
          },
          "style": "diamond",
          "template": "{{ if .Name }}pwsh::{{ .Name }}{{ end }}\ue0b2",
          "type": "az"
        },
        {
          "background": "#b2bec3",
          "foreground": "#000000",
          "leading_diamond": "\ue0b2",
          "properties": {
            "source": "cli"
          },
          "style": "diamond",
          "template": "{{ if .Name }}cli::{{ .Name }}{{ end }}\ue0b2",
          "type": "az"
        },
        {
          "background": "#40c4ff",
          "foreground": "#ffffff",
          "invert_powerline": true,
          "leading_diamond": "\ue0b2",
          "properties": {
            "time_format": "_2,15:04"
          },
          "style": "diamond",
          "template": " \uf073 {{ .CurrentDate | date .Format }} ",
          "trailing_diamond": "\ue0b4",
          "type": "time"
        }
      ],
      "type": "prompt"
    },
    {
      "alignment": "left",
      "newline": true,
      "segments": [
        {
          "foreground": "#21c7c7",
          "style": "plain",
          "template": "\u2570\u2500",
          "type": "text"
        },
        {
          "foreground": "#e0f8ff",
          "foreground_templates": ["{{ if gt .Code 0 }}#ef5350{{ end }}"],
          "properties": {
            "always_enabled": true
          },
          "style": "plain",
          "template": "\ue285\ueab6 ",
          "type": "status"
        }
      ],
      "type": "prompt"
    }
  ],
  "version": 2
}

What OS are you seeing the problem on?

Windows

Which shell are you using?

powershell

Log output

Segments:

ConsoleTitle(false) -   0 ms
Shell(true)         -   3 ms
Root(false)         -   1 ms
Path(true)          -   3 ms
Git(false)          -  17 ms
Executiontime(true) -   3 ms
Node(false)         -   0 ms
Python(false)       -   1 ms
Java(false)         -   0 ms
Dotnet(false)       -   0 ms
Go(false)           -   0 ms
Rust(false)         -   0 ms
Dart(false)         -   0 ms
Angular(false)      -   0 ms
Nx(false)           -   0 ms
Julia(false)        -   1 ms
Ruby(false)         -   0 ms
Azfunc(false)       -   0 ms
Aws(false)          -   0 ms
Kubectl(true)       -   4 ms
Az(true)            -   2 ms
Az(true)            -   1 ms
Time(true)          -   0 ms
Text(true)          -   0 ms
Status(true)        -   0 ms

Run duration: 1.1521845s

Cache path: C:\Users\PrestonRodriguez\AppData\Local\oh-my-posh

Config path: C:\Users\PrestonRodriguez\.mytheme.omp.json

Logs:

[DEBUG] 14:07:21.423 shell.go:Getenv:392 → NO DATA
[TRACE] 14:07:21.423 shell.go:Getenv(TERM_PROGRAM) - 503.7µs
[DEBUG] 14:07:21.423 shell.go:Getenv:392 → C:\Users\PrestonRodriguez\AppData\Local
[TRACE] 14:07:21.423 shell.go:Getenv(LOCALAPPDATA) - 0s
[TRACE] 14:07:21.423 shell_windows.go:CachePath() - 0s
[DEBUG] 14:07:21.423 shell.go:Getenv:392 → C:\Users\PrestonRodriguez\.mytheme.omp.json
[TRACE] 14:07:21.423 shell.go:Getenv(POSH_THEME) - 0s
[DEBUG] 14:07:21.423 shell.go:Shell:632 → no shell name provided in flags, trying to detect it
[DEBUG] 14:07:22.545 shell.go:Shell:640 → process name: powershell.exe
[TRACE] 14:07:22.545 shell.go:Shell() - 1.1225637s
[TRACE] 14:07:22.545 shell.go:resolveConfigPath() - 1.1225637s
[TRACE] 14:07:22.545 shell.go:Init() - 1.1231242s
[TRACE] 14:07:22.545 shell.go:Flags() - 0s
JanDeDobbeleer commented 1 year ago

@prestonr83 that isn't the issue, debug just doesn't have that flag like init does. If you run oh-my-posh debug --shell powershell you get the correct output. So you'll most likely have Defender or Virus scanner blocking the execution.

prestonr83 commented 1 year ago

That worked. Thanks

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.