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

Property `.Venv` get the wrong name in Python segment #4722

Closed rockyoung closed 8 months ago

rockyoung commented 8 months ago

Code of Conduct

What happened?

my virtual env is '.venv' but .Venv return the dir base name of the project, but it is correctly displayed when i switched to a conda env. 1709104439523

Theme

{
  "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
  "version": 2,
  "console_title_template": "{{.Shell}} in {{.Folder}}",
  "blocks": [
    {
      "type": "prompt",
      "alignment": "left",
      "segments": [
        {
          "type": "text",
          "style": "plain",
          "foreground": "#c386f1",
          "template": "\u250c"
        },
        {
          "type": "time",
          "style": "plain",
          "foreground": "#aaaaaa",
          "template": "<white>[</>{{.CurrentDate | date .Format}}<white>]</>",
          "properties": {
            "time_format": "\ue389PM_3:04, \uf073Mon,Jan 2"
          }
        },
        {
          "type": "sysinfo",
          "style": "plain",
          "foreground": "#81afde",
          "template": "<cyan>[</>\udb80\udf5bRAM:{{.PhysicalPercentUsed}}\uf295 "
        },
        {
          "type": "connection",
          "style": "plain",
          "foreground": "#ffffff",
          "template": "{{if eq .Type \"wifi\"}}\udb81\udda9{{else if eq .Type \"ethernet\"}}\udb80\ude00{{end}}"
        },
        {
          "type": "ipify",
          "style": "plain",
          "foreground": "#cccccc",
          "template": "{{ .IP }} ",
          "properties": {
            "cache_timeout": 15,
            "http_timeout": 1000
          }
        },
        {
          "type": "battery",
          "style": "plain",
          "foreground": "#193549",
          "foreground_templates": [
            "{{if eq \"Full\" .State.String}}#39bd3e{{end}}",
            "{{if eq \"Charging\" .State.String}}#4390d9{{end}}",
            "{{if eq \"Discharging\" .State.String}}#fcd188{{end}}"
          ],
          "template": "{{if not .Error}}{{.Icon}}{{.Percentage}}{{end}}\uf295<cyan>]</>",
          "properties": {
            "charged_icon": "\udb84\udea3\ue22f-",
            "charging_icon": "\udb84\udea3\ue234-",
            "discharging_icon": "\udb84\udea3\ue231-"
          }
        },
        {
          "type": "session",
          "style": "plain",
          "foreground": "#aaaaaa",
          "template": " \uf109{{.HostName}}@"
        },
        {
          "type": "os",
          "style": "plain",
          "foreground": "#ffffff",
          "background": "transparent",
          "template": "{{if .WSL}}WSL_{{end}}{{.Icon}}"
        },
        {
          "type": "root",
          "style": "plain",
          "foreground": "#ffff66",
          "background": "transparent",
          "template": " \uf12a\uf0e7"
        }
      ]
    },
    {
      "type": "prompt",
      "alignment": "left",
      "segments": [
        {
          "type": "text",
          "style": "plain",
          "foreground": "#c386f1",
          "template": "\u251c"
        },
        {
          "type": "session",
          "style": "plain",
          "foreground": "#ffffff",
          "template": "<green>[</>{{if .SSHSession}}\ueba9{{else}}\uf2be{{end}}{{.UserName}} "
        },
        {
          "type": "path",
          "style": "plain",
          "foreground": "#ff80bb",
          "template": "<#ffd255>\ue5fe</>{{.Path}}<green>]</>",
          "properties": {
            "folder_separator_icon": "<#c0c0c0>/</>",
            "max_depth": 3,
            "style": "agnoster_short"
          }
        },
        {
          "type": "git",
          "style": "diamond",
          "foreground": "#193549",
          "background": "#fffb38",
          "background_templates": [
            "{{if or (.Working.Changed) (.Staging.Changed)}}#ff9248{{end}}",
            "{{if and (gt .Ahead 0) (gt .Behind 0)}}#f26d50{{end}}",
            "{{if gt .Ahead 0}}#f17c37{{end}}",
            "{{if gt .Behind 0}}#89d1dc{{end}}"
          ],
          "leading_diamond": "\ue0b2",
          "template": "{{.HEAD}}{{if .BranchStatus}}{{.BranchStatus}}{{end}}{{if .Working.Changed}}{{.Working.String}}{{end}}{{if and (.Staging.Changed) (.Working.Changed)}}|{{end}}{{if .Staging.Changed}}\uf046{{.Staging.String}}{{end}}{{if gt .StashCount 0}}\uf0c7{{.StashCount}}{{end}}{{if gt .WorktreeCount 0}}\uf1bb{{.WorktreeCount}}{{end}}",
          "properties": {
            "fetch_stash_count": true,
            "fetch_status": true,
            "fetch_upstream_icon": true
          }
        }
      ],
      "newline": true
    },
    {
      "type": "prompt",
      "alignment": "left",
      "segments": [
        {
          "type": "text",
          "style": "plain",
          "foreground": "#c386f1",
          "template": "\u2514"
        },
        {
          "type": "aws",
          "style": "powerline",
          "powerline_symbol": "\ue0b0",
          "foreground": "#ffffff",
          "background_templates": [
            "{{if contains \"default\" .Profile}}#FFA400{{end}}",
            "{{if contains \"jan\" .Profile}}#f1184c{{end}}"
          ],
          "template": "\ue7ad{{.Profile}}{{if .Region}}@{{.Region}}{{end}}",
          "properties": {
            "display_default": false
          }
        },
        {
          "type": "azfunc",
          "style": "powerline",
          "powerline_symbol": "\ue0b0",
          "foreground": "#ffffff",
          "background": "#FEAC19",
          "template": "\uf0e7{{if .Error}}{{.Error}}{{else}}{{.Full}}{{end}}",
          "properties": {
            "display_mode": "files",
            "fetch_version": false
          }
        },
        {
          "type": "dart",
          "style": "powerline",
          "powerline_symbol": "\ue0b0",
          "foreground": "#ffffff",
          "background": "#06A4CE",
          "template": "\ue798{{if .Error}}{{.Error}}{{else}}{{.Full}}{{end}}"
        },
        {
          "type": "dotnet",
          "style": "powerline",
          "powerline_symbol": "\ue0b0",
          "foreground": "#000000",
          "background": "#00ffff",
          "template": "\ue77f{{if .Unsupported}}\uf071{{else}}{{.Full}}{{end}}"
        },
        {
          "type": "go",
          "style": "powerline",
          "powerline_symbol": "\ue0b0",
          "foreground": "#111111",
          "background": "#8ED1F7",
          "template": "\ue626{{if .Error}}{{.Error}}{{else}}{{.Full}}{{end}}",
          "properties": {
            "fetch_version": true
          }
        },
        {
          "type": "java",
          "style": "powerline",
          "powerline_symbol": "\ue0b0",
          "foreground": "#ffffff",
          "background": "#4063D8",
          "template": "\ue738{{if .Error}}{{.Error}}{{else}}{{.Full}}{{end}}"
        },
        {
          "type": "julia",
          "style": "powerline",
          "powerline_symbol": "\ue0b0",
          "foreground": "#111111",
          "background": "#4063D8",
          "template": "\ue624{{if .Error}}{{.Error}}{{else}}{{.Full}}{{end}}",
          "properties": {
            "fetch_version": true
          }
        },
        {
          "type": "node",
          "style": "powerline",
          "powerline_symbol": "\ue0b0",
          "foreground": "#ffffff",
          "background": "#6CA35E",
          "template": "\udb80\udf99{{if .PackageManagerIcon}}{{.PackageManagerIcon}} {{end}}{{.Full}}",
          "properties": {
            "fetch_version": true
          }
        },
        {
          "type": "python",
          "style": "powerline",
          "powerline_symbol": "\ue0b0",
          "foreground": "#111111",
          "background": "#FFDE57",
          "template": "\ue235{{.Venv}}",
          "properties": {
            "display_mode": "context"
          }
        },
        {
          "type": "ruby",
          "style": "powerline",
          "powerline_symbol": "\ue0b0",
          "foreground": "#ffffff",
          "background": "#AE1401",
          "template": "\ue791{{if .Error}}{{.Error}}{{else}}{{.Full}}{{end}}",
          "properties": {
            "display_mode": "files",
            "fetch_version": true
          }
        },
        {
          "type": "rust",
          "style": "powerline",
          "powerline_symbol": "\ue0b0",
          "foreground": "#193549",
          "background": "#99908a",
          "template": "\ue7a8{{if .Error}}{{.Error}}{{else}}{{.Full}}{{end}}"
        }
      ],
      "newline": true
    },
    {
      "type": "rprompt",
      "alignment": "right",
      "segments": [
        {
          "type": "text",
          "style": "diamond",
          "foreground": "#ffffff",
          "background": "#2e9599",
          "background_templates": [
            "{{if gt .Code 0}}#f1184c{{end}}"
          ],
          "leading_diamond": "\ue0c5",
          "template": "\ue23a{{if gt .Code 0}}\uf00d{{else}}\uf42e{{end}}",
          "properties": {
            "always_enabled": true
          }
        },
        {
          "type": "executiontime",
          "style": "diamond",
          "invert_powerline": true,
          "foreground": "#ffffff",
          "background": "#83769c",
          "trailing_diamond": "\ue0c4",
          "template": " \udb84\udfab{{.FormattedMs}}",
          "properties": {
            "always_enabled": true
          }
        }
      ],
      "overflow": "hide"
    }
  ]
}

What OS are you seeing the problem on?

No response

Which shell are you using?

No response

Log output

Version: 19.11.6

Shell: oh-my-posh (7.4.1)

Prompt:

┌[PM_3:16, Wed,Feb 28][󰍛RAM:48 󰈀cip 󱊣-100] pcn@
├[myn some/dir/MB-Lyric]main≡?1
└MB-Lyric

Segments:

ConsoleTitle(true)                         -   0 ms
Text(true)                                 -   0 ms
Time(true)                                 -   0 ms
Sysinfo(true)                              -   0 ms
Connection(true)                           -   8 ms
Ipify(true)                                -   0 ms
Battery(true)                              -  14 ms
Session(true)                              -   0 ms
Os(true)                                   -   0 ms
Root(false)                                -   0 ms
Text(true)                                 -   0 ms
Session(true)                              -   0 ms
Path(true)                                 -   1 ms
Git(true)                                  -  53 ms
Text(true)                                 -   0 ms
Aws(false)                                 -   0 ms
Azfunc(false)                              -   2 ms
Dart(false)                                -   2 ms
Dotnet(false)                              -   3 ms
Go(false)                                  -   1 ms
Java(false)                                -   3 ms
Julia(false)                               -   1 ms
Node(false)                                -   2 ms
Python(true)                               -  16 ms
Ruby(false)                                -   1 ms
Rust(false)                                -   2 ms
Text(true)                                 -   0 ms
Executiontime(true)                        -   0 ms

Run duration: 96.4929ms
rockyoung commented 8 months ago

ok, i checked the commit of source code, so why use parent dir name as the virtual env name when it is 'venv' or '.venv'??? Does all David use their fathers name?🤔

JanDeDobbeleer commented 8 months ago

Because according to users, .venv doesn't mean anything. If this isn't what you want, please create a feature request or PR that allows to toggle this behaviour.

rockyoung commented 8 months ago

Because according to users, .venv doesn't mean anything. If this isn't what you want, please create a feature request or PR that allows to toggle this behaviour.

yup, have made a #PR

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