JanDeDobbeleer / oh-my-posh

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

"display_version" and "display_mode" in python segment do not work #804

Closed ruicx closed 3 years ago

ruicx commented 3 years ago

Prerequisites

Description

Following the document, I set display_version to false and display_mode to always, but they seem not work.

Environment

Optional

Steps to Reproduce

  1. Set the theme to agnoster-brief

Expected behavior: [What you expected to happen]

  1. No python version shown
  2. Conda environment name shows, whatever a .py file exists

In brief, I hope it looks like this:

image

Actual behavior: [What actually happened]

image


My theme (agnoster-brief.omp.json)

{
  "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
  "blocks": [
    {
      "type": "prompt",
      "alignment": "left",
      "segments": [
        {
          "type": "root",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#100e23",
          "background": "#ffe9aa"
        },
        {
          "type": "path",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#100e23",
          "background": "#91ddff",
          "properties" : {
              "home_icon": "\uF7DB",
              "folder_icon": "\uF115",
              "folder_separator_icon": " \uE0B1 ",
              "style": "agnoster_short"
          }
        },
        {
          "type": "git",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#193549",
          "background": "#95ffa4"
        },
        {
          "type": "python",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#100e23",
          "background": "#906cff",
          "display_mode": "always",
          "display_default": "true",
          "display_virtual_env": "true",
          "display_version": "false",
          "properties": {
            "prefix": " \uE235 "
          }
        },
        {
          "type": "exit",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#ffffff",
          "background": "#ff8080"
        }
      ]
    }
  ],
  "final_space": true
}
JanDeDobbeleer commented 3 years ago

@ruicx that's because you added those settings to the segment rather than the properties. Adjusting the python segment to contain those overrides in the properties makes it work as desired:

{
  "type": "python",
  "style": "powerline",
  "powerline_symbol": "\uE0B0",
  "foreground": "#100e23",
  "background": "#906cff",
  "properties": {
    "prefix": " \uE235 ",
    "display_mode": "always",
    "display_default": true,
    "display_virtual_env": true,
    "display_version": false
  }
}
ruicx commented 3 years ago
{
  "type": "python",
  "style": "powerline",
  "powerline_symbol": "\uE0B0",
  "foreground": "#100e23",
  "background": "#906cff",
  "properties": {
    "prefix": " \uE235 ",
    "display_mode": "always",
    "display_default": true,
    "display_virtual_env": true,
    "display_version": false
  }
} 

Thanks a lot.

I move them to properties, and Conda env name fixed, but the python version is still shown.

image

JanDeDobbeleer commented 3 years ago

@ruicx on my machine it only displays base with the exact same configuration. Unless the python version is part of the virtual env name, then it can off course still be displayed.

image

The first time is with "display_version": true, the second run is as you have it here.

ruicx commented 3 years ago

I switched to Oh-My-Posh V3 from V2 earlier today, and in v2 only the prompt only shows base, and my env name doesn't contain a version number. Perhaps, there are some issues with my environment variables. Whatever, the version number is not critical. Thanks for your time.

image

JanDeDobbeleer commented 3 years ago

@ruicx are you certain you've set the right config?

ruicx commented 3 years ago

I accidentally replaced false with "false" on formatting the JSON file. Switching to the correct one, now, it works.

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.