oh-my-posh: Powerline symbols not rendered when text value is empty

Code of Conduct

  • I agree to follow this project’s Code of Conduct

What happened?

Can’t say when, but my prompt got a bit broken by one of the updates. I have the following segment:

        {
          "background": "#d3d7cf",
          "foreground": "#000000",
          "invert_powerline": true,
          "powerline_symbol": "",
          "properties": {
            "prefix": "",
            "postfix": "",
            "text": ""
          },
          "style": "powerline",
          "type":"text"
        },
        {
          "background": "#d3d7cf",
          "foreground": "#000000",
           "invert_powerline": true,
          "leading_diamond": "",
          "properties": {
            "prefix": "",
            "postfix": "  "
          },
          "style": "diamond",
          "type": "time"
        }

It was working as expected before showing time like this: obraz

Now it looks like this: obraz

It looks like the powerline symbol is not rendered when the text is empty. When I set it to a space " ", it works but adds fair amount of space: obraz

I know that you’ll probably say that I should use “leading_diamond” property, but that does not produce the effect I’m going for. At first I thought it did: obraz

But well…it doesn’t 😉 obraz

Version

5.16.2

Theme

Powerline10k_rainbow with minor modifications

What OS are you seeing the problem on?

Windows

Which shell are you using?

powershell

Relevant log output

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (9 by maintainers)

Commits related to this issue

Most upvoted comments

should be fixed by https://github.com/JanDeDobbeleer/oh-my-posh/pull/1134 keep your template as before and it will work once the pull is merged.

@mwasowski here you go, diamond is what you want all the way down 😉

{
  "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh3/main/themes/schema.json",
  "blocks": [
    {
      "alignment": "left",
      "newline": true,
      "segments": [],
      "type": "prompt"
    },
    {
      "alignment": "left",
      "newline": true,
      "segments": [
        {
          "background": "#d3d7cf",
          "foreground": "#000000",
          "style": "diamond",
          "type": "os"
        },
        {
          "background": "#3465a4",
          "foreground": "#e4e4e4",
          "powerline_symbol": "",
          "properties": {
            "home_icon": "~",
            "prefix": "  ",
            "style": "full"
          },
          "style": "powerline",
          "type": "path"
        },
        {
          "background": "#4e9a06",
          "foreground": "#000000",
          "powerline_symbol": "",
          "properties": {
            "ahead_and_behind_color": "#f26d50",
            "ahead_color": "#89d1dc",
            "behind_color": "#4e9a06",
            "branch_icon": " ",
                  "display_status": true,
            "display_stash_count": true,
            "display_upstream_icon": true,
            "local_changes_color": "#c4a000",
            "stash_count_icon": " ",
            "status_colors_enabled": true
          },
          "style": "powerline",
          "type": "git"
        }
      ],
      "type": "prompt"
    },
    {
      "alignment": "right",
      "segments": [
        {
          "background": "#689f63",
          "foreground": "#ffffff",
          "leading_diamond": "<background,inherit></>",
          "properties": {
            "display_version": true,
            "postfix": " "
          },
          "style": "diamond",
          "type": "node"
        },
        {
          "background": "#00acd7",
          "foreground": "#111111",
          "leading_diamond": "<background,inherit></>",
          "properties": {
            "display_version": true,
            "postfix": " "
          },
          "style": "diamond",
          "type": "go"
        },
        {
          "background": "#FFDE57",
          "foreground": "#111111",
          "leading_diamond": "<background,inherit></>",
          "properties": {
            "display_mode": "files",
            "display_version": true,
            "display_virtual_env": false,
            "postfix": " "
          },
          "style": "diamond",
          "type": "python"
        },
        {
          "background": "#AE1401",
          "foreground": "#ffffff",
          "leading_diamond": "<background,inherit></>",
          "properties": {
            "display_mode": "files",
            "display_version": true,
            "postfix": " "
          },
          "style": "diamond",
          "type": "ruby"
        },
        {
          "background": "#FEAC19",
          "foreground": "#ffffff",
          "leading_diamond": "<background,inherit></>",
          "properties": {
            "display_mode": "files",
            "display_version": false,
            "postfix": " "
          },
          "style": "diamond",
          "type": "azfunc"
        },
        {
          "background_templates": [
            "{{if contains \"default\" .Profile}}#FFA400{{end}}",
            "{{if contains \"Michał\" .Profile}}#f1184c{{end}}"
          ],
          "foreground": "#ffffff",
          "leading_diamond": "<background,inherit></>",
          "properties": {
            "display_default": false,
            "postfix": " "
          },
          "style": "diamond",
          "type": "aws"
        },
        {
          "background": "#000000",
          "foreground": "#d3d7cf",
          "leading_diamond": "<background,inherit></>",
          "properties": {
            "always_enabled": false,
            "color_background": true,
            "display_exit_code": true,
            "error_color": "#cc2222"
          },
          "style": "diamond",
          "type": "exit"
        },
        {
          "background": "#ffff66",
          "foreground": "#111111",
          "leading_diamond": "<background,inherit></>",
          "properties": {
            "root_icon": ""
          },
          "style": "diamond",
          "type": "root"
        },
        {
          "background": "#c4a000",
          "foreground": "#000000",
          "leading_diamond": "<background,inherit></>",
          "properties": {
            "always_enabled": false,
            "threshold": 100,
            "postfix": "  "
          },
          "style": "diamond",
          "type": "executiontime"
        },
        {
          "background": "#d3d7cf",
          "foreground": "#000000",
          "leading_diamond": "<background,inherit></>",
          "properties": {
            "prefix": " ",
            "postfix": "  "
          },
          "style": "diamond",
          "type": "time"
        }
      ],
      "type": "prompt"
    },
    {
      "alignment": "left",
      "newline": true,
      "segments": [
        {
          "foreground": "#007ACC",
          "properties": {
            "prefix": "",
            "postfix": "",
            "text": "❯"
          },
          "style": "plain",
          "type": "text"
        }
      ],
      "type": "prompt"
    }
  ],
  "console_title": true,
  "console_title_style": "template",
  "console_title_template": "{{ .Shell }} in {{ .Folder }}",
  "final_space": true,
  "transient_prompt": {
    "background": "transparent",
    "foreground": "#007ACC",
    "template": "❯ "
  }
}

Ah, I have an issue with reading and understanding apparently 😄 You wrote I can use background everywhere 🤦‍♂️

Thanks again!

@mwasowski when the change above lands, this seems to work like a charm:

{
    "style": "plain",
    "type": "exit",
    "background": "#AF3322",
    "foreground": "#ffffff",
    "properties": {
        "prefix": "<#AF3322,transparent></> "
    }
},
{
    "background": "#d3d7cf",
    "foreground": "#000000",
    "invert_powerline": true,
    "leading_diamond": "<#d3d7cf,inherit></>",
    "properties": {
        "prefix": " ",
        "postfix": "  "
    },
    "style": "diamond",
    "type": "time"
}

It’s related to this change(text segment not rendered if empty) https://github.com/JanDeDobbeleer/oh-my-posh/commit/d0816773a51c0ab62016d91294902fe7bd38ed91 Your sample works if I revert it

this works for example:

{
          "background": "#d3d7cf",
          "foreground": "#000000",
          "invert_powerline": true,
          "powerline_symbol": "",
          "properties": {
            "prefix": "",
            "postfix": "",
            "text": ""
          },
          "style": "powerline",
          "type":"text"
        },
        {
          "background": "#d3d7cf",
          "foreground": "#000000",
           "invert_powerline": true,
           "powerline_symbol": "",
          "leading_diamond": "",
          "properties": {
            "prefix": "",
            "postfix": "  "
          },
          "style": "diamond",
          "type": "time"
        }

@JanDeDobbeleer Yes. I closed it before testing but 5.16.3 did not fix this for me. So with no preceding segment it looks like this: obraz And with like this. obraz

@mwasowski that’s probably the issue @lnu found and what’s supposedly going to be fixed here.