JanDeDobbeleer / oh-my-posh

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

Execution time segment spacing varies based on prefix icon #952

Closed xt0rted closed 3 years ago

xt0rted commented 3 years ago

Code of Conduct

What happened?

While playing around with my theme's colors I found that the execution time prefix causes extra space at the start or end of the segment, and sometimes no space between the prefix and the time, depending on the icon used.

image

This is the config used in each of those lines:

  1. "prefix": " <#fafafa>\ufa1e</> "
  2. "prefix": " <#fafafa>\ufbab</> "
  3. "prefix": " <#fafafa>\ufbab</> "
  4. "prefix": " <#fafafa>\ufc8a</> "
  5. "prefix": " <#fafafa>\uf608</> "

Removing the trailing space also effects the icon placement by moving it to the left even more.

I'm using PowerShell Core and WSL Bash in Windows Terminal. The font is MesloLGM NF.

Version

Theme

{
    "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
    "final_space": false,
    "osc99": false,
    "console_title": true,
    "console_title_style": "template",
    "console_title_template": "{{if .Root}}∞ {{end}}{{.Path}}",
    "blocks": [
        {
            "type": "prompt",
            "alignment": "left",
            "horizontal_offset": 0,
            "vertical_offset": 0,
            "segments": [
                {
                    "type": "shell",
                    "style": "powerline",
                    "foreground": "#fafafa", // gray-50
                    "background": "#0077c2",
                    "properties": {
                        "prefix": " \uFCB5 "
                    }
                },
                {
                    "type": "root",
                    "style": "powerline",
                    "powerline_symbol": "\uE0B0",
                    "invert_powerline": false,
                    "foreground": "#ef4444", // yellow-200
                    "foreground_templates": null,
                    "background": "#fef08a", // red-500
                    "background_templates": null,
                    "leading_diamond": "",
                    "trailing_diamond": "",
                    "properties": null
                },
                {
                    "type": "exit",
                    "style": "powerline",
                    "powerline_symbol": "\uE0B0",
                    "invert_powerline": false,
                    "foreground": "#fafafa", // gray-50,
                    "foreground_templates": null,
                    "background": "#ef4444", // red-500
                    "background_templates": null,
                    "leading_diamond": "",
                    "trailing_diamond": "",
                    "properties": {
                        "prefix": "  "
                    }
                },
                {
                    "type": "executiontime",
                    "style": "powerline",
                    "powerline_symbol": "\uE0B0",
                    "foreground": "#fafafa", // gray-50,
                    "background": "#9333ea", // purple-600
                    "properties": {
                      "threshold": 500,
                      "prefix": " <#fafafa>\ufa1e</> "
                    }
                },
                {
                    "type": "envvar",
                    "style": "powerline",
                    "powerline_symbol": "\uE0B0",
                    "foreground": "#fafafa", // gray-50,
                    "background": "#592B8D",
                    "properties": {
                        "var_name": "OMP_VSEnvironment"
                    }
                },
                {
                    "type": "az",
                    "style": "powerline",
                    "powerline_symbol": "\uE0B0",
                    "foreground": "#171717", // true-gray-900
                    "background": "#38bdf8", // sky-400
                    "properties": {
                        "display_id": true,
                        "display_name": true,
                        "info_separator": " @ ",
                        "prefix": " \uFD03 "
                    }
                },
                {
                    "type": "session",
                    "style": "powerline",
                    "powerline_symbol": "\uE0B0",
                    "invert_powerline": false,
                    "foreground": "#171717", // true-gray-900
                    "foreground_templates": null,
                    "background": "#fafafa", // gray-50,
                    "background_templates": null,
                    "leading_diamond": "",
                    "trailing_diamond": "",
                    "properties": {
                        "default_user_name": "brian",
                        "display_default": false,
                        "display_host": false
                    }
                },
                {
                    "type": "path",
                    "style": "powerline",
                    "powerline_symbol": "\uE0B0",
                    "invert_powerline": false,
                    "foreground": "#171717", // true-gray-900
                    "foreground_templates": null,
                    "background": "#7dd3fc", // sky-300
                    "background_templates": null,
                    "leading_diamond": "",
                    "trailing_diamond": "",
                    "properties": {
                        "folder_icon": "",
                        "style": "full",
                        "enable_hyperlink": true,
                        "mapped_locations": {
                            "C:\\dev\\test\\.worktrees": "test\\\uF1BB"
                        }
                    }
                },
                {
                    "type": "git",
                    "style": "powerline",
                    "powerline_symbol": "\uE0B0",
                    "invert_powerline": false,
                    "foreground": "#fafafa", // gray-50,
                    "foreground_templates": null,
                    "background": "#171717", // true-gray-900
                    "background_templates": null,
                    "leading_diamond": "",
                    "trailing_diamond": "",
                    "properties": {
                        "display_status": true,
                        "display_stash_count": true,
                        "display_upstream_icon": false,
                        "display_worktree_count": true,
                        "working_color": "red"
                    }
                },
                {
                    "type": "dotnet",
                    "style": "powerline",
                    "powerline_symbol": "\uE0B0",
                    "foreground": "#fafafa", // gray-50,
                    "background": "#512bd4", // dotnet-purple
                    "properties": {
                        "prefix": " \uE77F "
                    }
                },
                {
                    "type": "node",
                    "style": "powerline",
                    "powerline_symbol": "\uE0B0",
                    "foreground": "#fafafa", // gray-50,
                    "background": "#6F9F60", // node-logo-mark-green
                    "properties": {
                        "prefix": " \uE718 ",
                        "display_package_manager": true
                    }
                },
                {
                    "type": "python",
                    "style": "powerline",
                    "powerline_symbol": "\uE0B0",
                    "foreground": "#171717", // true-gray-900
                    "background": "#906cff",
                    "properties": {
                        "display_mode": "context",
                        "prefix": " \uE235 "
                    }
                }
            ]
        },
        {
            "type": "prompt",
            "alignment": "right",
            "segments": [
                {
                    "type": "time",
                    "style": "plain",
                    "foreground": "#fafafa", // gray-50,
                    "properties": {
                        "prefix": "[",
                        "postfix": "]",
                        "time_format": "15:04:05"
                    }
                }
            ]
        },
        {
            "type": "prompt",
            "newline": true,
            "alignment": "left",
            "horizontal_offset": 0,
            "vertical_offset": 0,
            "segments": [
                {
                    "type": "text",
                    "style": "plain",
                    "powerline_symbol": "",
                    "foreground": "#fafafa", // gray-50,
                    "properties": {
                        "prefix": "",
                        "text": "\u276F"
                    }
                }
            ]
        }
    ]
}

What OS are you seeing the problem on?

Windows, Linux

Which shell are you using?

bash, powershell

Relevant log output

No response

xt0rted commented 3 years ago

It looks like the prefix color changes where the blank space shows. Using #fafafa it's at the end of the segment, using #fefefe it's between the icon & time.

image

  1. "prefix": " <#fafafa>\ufa1e</> "
  2. "prefix": " <#fefefe>\ufa1e</> "
JanDeDobbeleer commented 3 years ago

@xt0rted that's a bug in Windows Terminal. We have an FAQ item about it.

xt0rted commented 3 years ago

Thanks for the info.

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