JanDeDobbeleer / oh-my-posh

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

Missing characters on first line when powershell starts #864

Closed Balkoth closed 3 years ago

Balkoth commented 3 years ago

image

image

Prerequisites

Description

The first line of a new windows terminal powershell instance misses out on some characters.

Environment

Optional

JanDeDobbeleer commented 3 years ago

@Balkoth that's a Windows Terminal bug. The fix can be found here.

Balkoth commented 3 years ago

Sorry but the fix does not work for me. Version 2 does not have this problem.

JanDeDobbeleer commented 3 years ago

@Balkoth the bug is not in oh-my-posh, but Windows Terminal and icons/ANSI. So if it doesn't work, please follow up on the linked issue so they can fix it.

david-baierl commented 3 years ago

For my workes adding echo '' at the end of my .bashrc file to force a new line bevor printing anything

hyoretsu commented 2 years ago

@Balkoth that's a Windows Terminal bug. The fix can be found here.

The worked for me. In my case, whitespace at the end wasn't rendering the background color. At first Windows Terminal displayed it correctly, but after some time it didn't.

t0m5k1 commented 1 year ago

I too face this issue but I'm lost as to how I fix it...

@Balkoth that's a Windows Terminal bug. The fix can be found here.

This is great but where do I put the code from this FAQ ? settings.json or profile.ps1 or some other file I'm not familiar with??

I feel this needs more scope on what people should actually be doing with the code snippet rather than blindly giving it out and expecting people to know exactly where it belongs

JanDeDobbeleer commented 1 year ago

@t0m5k1 this needs to be added to the configuration. In case you're using a theme, export it first using this guide. I do see an issue with the snippet in the FAQ, template is now part of the root object rather than properties:

{
  "type": "executiontime",
  "template": "\ufbab\u2800" // invisible spacing character
}
t0m5k1 commented 1 year ago

Think I'll just live with the gap.

JanDeDobbeleer commented 1 year ago

@t0m5k1 why? It's not that hard, follow the steps and adjust the template accordingly (or ask the WT team to fix their terminal 😁)

t0m5k1 commented 1 year ago

Because I've done what you said and added the 4 lines of code but it's not taking effect. Seeing as you created this I guess I have wider issues that I just don't have the time to look into. I've no idea what I'm doing, I'm not a coder in any way and this at then end of the day is eye candy which can be lived with as PS is still usable.

JanDeDobbeleer commented 1 year ago

@t0m5k1 can you share the config you adjusted? I'll help you.

t0m5k1 commented 1 year ago

Here you go: https://pastebin.com/B61xTesV

JanDeDobbeleer commented 1 year ago

@t0m5k1 can you show me a screenshot of where the gap is? That way I can adjust the config accordingly. From what I can see in the shared config, is that you seem to be confused as to where to adjust the correct template. You added the example I gave at random places, which won't do what you're trying to achieve. I'll try to explain it better, but it's also advised to read the docs on how this all works, otherwise you'll get confused even more when trying to adjust other elements.

Every segment has a template that defines how the content is rendered. In your example, the first block has the session segment first, defined like:

{
  "type": "session",
  "style": "diamond",
  "foreground": "p:black",
  "background": "p:yellow",
  "leading_diamond": "\ue0b6",
  "trailing_diamond": "\ue0b0",
  "template": " {{ if .SSHSession }}\uf817 {{ end }}{{ .UserName }} "
}

Here, the template says it will print the \uf817 icon if we have an active .SSHSession, see each segment template properties for possibilities here. Suppose that the \uf817 icon has a space after it, like what you see in your prompt, we can use the invisible character hack to have Windows Terminal display it correctly by appending \u2800 to the broken character:

{
  "type": "session",
  "style": "diamond",
  "foreground": "p:black",
  "background": "p:yellow",
  "leading_diamond": "\ue0b6",
  "trailing_diamond": "\ue0b0",
  "template": " {{ if .SSHSession }}\uf817\u2800 {{ end }}{{ .UserName }} "
}

So, in your case, check where the prompt has that space, which is always after a specific character and add it to that template, after the broken character and it should be solved. If not, change the icon to a different one, there's a whole cheat sheet for this over at Nerd Fonts.

t0m5k1 commented 1 year ago

Hi Jan, Thanks for pointing out where I went wrong with this. I think it would be better if the FAQ gave some additional detail in so much as that it should state that every single segment needs to have this added because that's what lead me to do what I did! I also stated "I'm not a coder in any way!" Therefore I wouldn't have the slightest idea where to put the template.

As I said previously I'll just live with it the way it is, If I go poking around any further I'll have even less of a clue of what I did ..I'm kinda getting used to it and it is just eye candy. Additionally I have a feeling I'll need to reverse all this when MS decide to fix what ever is broken. Cheers

JanDeDobbeleer commented 1 year ago

@t0m5k1 good pointer, I'll add that to the FAQ that way.

JanDeDobbeleer commented 1 year ago

@t0m5k1 #3776

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