JanDeDobbeleer / oh-my-posh

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

Can't modify theme Paradox #425

Closed johnknoop closed 3 years ago

johnknoop commented 3 years ago

I'm using V3 and I'm trying the steps outlined in this guide:

image

But I like Paradox rather than jandedobbeleer, so I try out the steps with Paradox:

image

But as you can see, it now says "invalid config".

johnknoop commented 3 years ago

This is the contents of the generated file .go-my-posh-.json:

{
    "final_space": false,
    "osc99": false,
    "console_title": false,
    "console_title_style": "",
    "console_title_template": "",
    "blocks": [
        {
            "type": "prompt",
            "alignment": "left",
            "horizontal_offset": 0,
            "vertical_offset": 0,
            "segments": [
                {
                    "type": "root",
                    "style": "powerline",
                    "powerline_symbol": "",
                    "invert_powerline": false,
                    "foreground": "#100e23",
                    "foreground_templates": null,
                    "background": "#ffe9aa",
                    "background_templates": null,
                    "leading_diamond": "",
                    "trailing_diamond": "",
                    "properties": null
                },
                {
                    "type": "session",
                    "style": "powerline",
                    "powerline_symbol": "",
                    "invert_powerline": false,
                    "foreground": "#100e23",
                    "foreground_templates": null,
                    "background": "#ffffff",
                    "background_templates": null,
                    "leading_diamond": "",
                    "trailing_diamond": "",
                    "properties": null
                },
                {
                    "type": "path",
                    "style": "powerline",
                    "powerline_symbol": "",
                    "invert_powerline": false,
                    "foreground": "#100e23",
                    "foreground_templates": null,
                    "background": "#91ddff",
                    "background_templates": null,
                    "leading_diamond": "",
                    "trailing_diamond": "",
                    "properties": {
                        "folder_icon": "",
                        "folder_separator_icon": "",
                        "style": "full"
                    }
                },
                {
                    "type": "git",
                    "style": "powerline",
                    "powerline_symbol": "",
                    "invert_powerline": false,
                    "foreground": "#193549",
                    "foreground_templates": null,
                    "background": "#95ffa4",
                    "background_templates": null,
                    "leading_diamond": "",
                    "trailing_diamond": "",
                    "properties": null
                },
                {
                    "type": "python",
                    "style": "powerline",
                    "powerline_symbol": "",
                    "invert_powerline": false,
                    "foreground": "#100e23",
                    "foreground_templates": null,
                    "background": "#906cff",
                    "background_templates": null,
                    "leading_diamond": "",
                    "trailing_diamond": "",
                    "properties": {
                        "prefix": "  "
                    }
                },
                {
                    "type": "exit",
                    "style": "powerline",
                    "powerline_symbol": "",
                    "invert_powerline": false,
                    "foreground": "#ffffff",
                    "foreground_templates": null,
                    "background": "#ff8080",
                    "background_templates": null,
                    "leading_diamond": "",
                    "trailing_diamond": "",
                    "properties": {
                        "prefix": " "
                    }
                }
            ]
        },
        {
            "type": "newline",
            "alignment": "",
            "horizontal_offset": 0,
            "vertical_offset": 0,
            "segments": null
        },
        {
            "type": "prompt",
            "alignment": "left",
            "horizontal_offset": 0,
            "vertical_offset": 0,
            "segments": [
                {
                    "type": "text",
                    "style": "plain",
                    "powerline_symbol": "",
                    "invert_powerline": false,
                    "foreground": "#007ACC",
                    "foreground_templates": null,
                    "background": "",
                    "background_templates": null,
                    "leading_diamond": "",
                    "trailing_diamond": "",
                    "properties": {
                        "prefix": "",
                        "text": "❯"
                    }
                }
            ]
        }
    ]
}
JanDeDobbeleer commented 3 years ago

@johnknoop try the full path rather than ~ and allow me to fix that annoying issue (only happens when using the module)

johnknoop commented 3 years ago

@JanDeDobbeleer same thing seems to happen when using the full path:

image

JanDeDobbeleer commented 3 years ago

Oh wait, my mistake. I think it's the null fields being exported. I'll check later today, and hopefully then fix the export to not include those.

JanDeDobbeleer commented 3 years ago

Hmm. When I add the above theme to a file, I actually get a rendered prompt. Let's validate on Windows.

image
JanDeDobbeleer commented 3 years ago

Same on Windows, works like a charm. Starting to think this is related to encoding rather than something oh-my-posh is influencing.

image

@johnknoop I need more information here:

Environment

johnknoop commented 3 years ago

Sure.

Oh my Posh version: 3.94.2 Theme: Paradox Operating System: Windows 10 Shell: Powershell 7.1.2 Terminal: Windows Terminal

JanDeDobbeleer commented 3 years ago

@johnknoop when you copy-paste the contents of the theme as described here, does it work then?

johnknoop commented 3 years ago

Same thing happens :(

johnknoop commented 3 years ago

I can at least confirm that it locates the file correctly, because if I run Set-PoshPrompt with an invalid path then I get a slightly different prompt afterwards.

JanDeDobbeleer commented 3 years ago

@johnknoop ok. That's the first time we see this issue. We've excluded the values in the export, the path is also correct yet somehow it can't parse the file's content correctly. I'll try to provide a build that outputs the actual error later today.

9/10 it's going to be file encoding as the default themes are included and work (autocomplete on Set-PoshPrompt). Which means calling the included scripts directly should work: Set-PoshPrompt -Theme "$((Get-Module oh-my-posh).ModuleBase)/themes/paradox.omp.json".

johnknoop commented 3 years ago

Thanks! Let me know when it's deployed and I'll run it and see what it says.

sid-6581 commented 3 years ago

Speaking of colors, hopefully my issue is related enough to tag onto this issue. I just updated to the new version, and I also use Paradox. Previously I believe it just used the ANSI colors, but now it uses hardcoded colors that clash with the colors I use in my terminal. Are there versions of these themes that use the ANSI colors? In particular Paradox.

JanDeDobbeleer commented 3 years ago

@sid-6581 we support hex color codes as well as ANSI colors. See here for more info on that.

@johnknoop I have a binary that prints the information we're looking for. Extract the file in it, navigate to that folder in your terminal and run it with your config .\posh-windows-amd64.exe --config ~/.go-my-posh.json. That should at least give an indication of the issue at hand.

sid-6581 commented 3 years ago

@JanDeDobbeleer I did see in the documentation that ANSI colors are supported, my question was more along the lines of whether there are versions of the themes that use ANSI colors instead of hex color codes. The previous version of paradox looked fine in my terminal, but the new one has hardcoded hex colors that don't look good with my terminal colors. Do I have to go and modify the theme by hand?

JanDeDobbeleer commented 3 years ago

@sid-6581 yes. The whole idea behind the current themes is that they serve more as samples rather than out of the box themes (can be, just not always what you want). With a json config the theme can also be carried cross shell/environment, making it super portable.

johnknoop commented 3 years ago

@JanDeDobbeleer does it write to a log file or something? Because it doens't write anything to the console:

image

johnknoop commented 3 years ago

Oh, hold on. Now I see "invalid config path".

johnknoop commented 3 years ago

Now we get some more info!

image

johnknoop commented 3 years ago

It turns out the json file was saved with a BOM. As soon as I removed that, it starts working!

johnknoop commented 3 years ago

Thanks a lot for the help you provided.

JanDeDobbeleer commented 3 years ago

Maybe we can do a structural change here that sets the output encoding correctly and saves the file correctly. Because this will happen more often now that we're out of beta.

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