Giter VIP home page Giter VIP logo

Comments (25)

JanDeDobbeleer avatar JanDeDobbeleer commented on September 13, 2024 1

@Bilge weird this has never been reported before. I can try to have a look.

from oh-my-posh.

JanDeDobbeleer avatar JanDeDobbeleer commented on September 13, 2024 1

Due to git bash' broken nature it can't interact nicely with the native Windows API and thus reported the incorrect terminal width. Fix incoming.

from oh-my-posh.

JanDeDobbeleer avatar JanDeDobbeleer commented on September 13, 2024 1

@Bilge after a good night's rest, I found the issue and oh-my-posh is responsible. We escape \ as it's used inside PS1 to control escape sequences and substitution, but it resulted in having the incorrect prompt length count. I have a draft ready that needs one more addition before being able to merge, but can confirm this is cleaner and solves the issue entirely.

image

from oh-my-posh.

JanDeDobbeleer avatar JanDeDobbeleer commented on September 13, 2024 1

@hungnguyen1503 set COLUMNS=0 just before the oh-my-posh init line. I'll fix it ASAP. Wasn't aware there were bash versions that do not set that variable.

from oh-my-posh.

Bilge avatar Bilge commented on September 13, 2024

Thanks for the fast fix 🙂 👍🏻

The default theme is right-aligned; my (slightly modified) version of P10K is not quite aligned to the right-hand edge but that probably just requires some tweaking.

from oh-my-posh.

Bilge avatar Bilge commented on September 13, 2024

Actually, it's still doing the weird thing where descending into directories is pulling further and further away from the right-hand edge. Only in the home directory is it flush against the right-hand side.

image

from oh-my-posh.

JanDeDobbeleer avatar JanDeDobbeleer commented on September 13, 2024

I'll have a look, this shouldn't happen although it can be another git bash bug. Does the same happen inside Windows Terminal?

from oh-my-posh.

Bilge avatar Bilge commented on September 13, 2024

It does not happen in PowerShell in Windows Terminal... although it's not really a fair test since I'm not using the Nerd font in Windows Terminal (nor am I using Bash). I tried to get it to run in WSL 1, but it doesn't work because the init script spits out the host path instead of the mounted path in WSL.

from oh-my-posh.

JanDeDobbeleer avatar JanDeDobbeleer commented on September 13, 2024

@Bilge you can run bash also in Windows Terminal, doesn't need to be PWSH.

from oh-my-posh.

Bilge avatar Bilge commented on September 13, 2024

Sure, but it keeps messing up the path. Whether under WSL 1 or just cmd.exe, for some reason the path to oh-my-posh.exe is /mnt/c/Program Files (x86)/oh-my-posh/bin/oh-my-posh.exe, but the init script keeps spitting out, C:/Program Files (x86)/oh-my-posh/bin/oh-my-posh.exe, which it cannot find (another bug?).

To be clear, the init script is the same under git Bash, but git Bash is clever in that it automatically remaps references to C:/; other environments cannot do that.

from oh-my-posh.

JanDeDobbeleer avatar JanDeDobbeleer commented on September 13, 2024

@Bilge not a bug. When using WSL, you need to use the linux executable. I meant you can run git bash, which is a Windows runtime faking linux tooling, inside Terminal. WSL is a linux runtime, so it needs to Linux oh-my-posh to work.

from oh-my-posh.

Bilge avatar Bilge commented on September 13, 2024

So you claim, and yet WSL 1 can run Windows native binaries, including oh-my-posh just fine. After all, it spits out the init script, it's only the paths that are incorrect. Case in point, oh-my-posh.exe print primary also works in WSL 1. I could probably search/replace the path references and it would work as expected.

Of course, what you are suggesting isn't wrong; I could install it twice, using the native runtime, it's just that I don't want to install it twice 🙂

from oh-my-posh.

JanDeDobbeleer avatar JanDeDobbeleer commented on September 13, 2024

@Bilge I know it can, and on WSL1 it will be "fast", on 2 slow and it's going to interact with Windows API's whereas the context is actually a linux runtime. It can be solved, but I purposefully don't do that. It's not a good idea.

from oh-my-posh.

Bilge avatar Bilge commented on September 13, 2024

Anyway, using the print primary command, I can see that there is no such issue under Windows Terminal (with its default font), so it's either a font issue or a git Bash issue.

from oh-my-posh.

JanDeDobbeleer avatar JanDeDobbeleer commented on September 13, 2024

@Bilge I'm going to have a look, always interesting.

from oh-my-posh.

Bilge avatar Bilge commented on September 13, 2024

Having installed the LiterationMono Nerd Font in Windows Terminal, it still seems to be printing consistent widths (with consistent right-alignment), so the alignment issue seems to be purely isolated to git Bash. Probably I am the only one trying to use OMP in the git Bash environment, which is why none of these issues have been discovered before 😆

from oh-my-posh.

JanDeDobbeleer avatar JanDeDobbeleer commented on September 13, 2024

@Bilge trust me, there are plenty 😁 But, people do tend to use Windows Terminal with git bash rather than mintty.

from oh-my-posh.

Bilge avatar Bilge commented on September 13, 2024

Uh... git Bash uses mintty. They are, effectively, one and the same.

from oh-my-posh.

JanDeDobbeleer avatar JanDeDobbeleer commented on September 13, 2024

@Bilge mintty is the terminal emulator, not the shell. You can run git bash as is inside Windows Terminal.

from oh-my-posh.

Bilge avatar Bilge commented on September 13, 2024

Oh, heh. Well I ran the git Bash specific flavour of Bash inside WSL 1 and it actually exhibits the same behaviour. So it is a git Bash issue (probably not a mintty issue).

image

from oh-my-posh.

JanDeDobbeleer avatar JanDeDobbeleer commented on September 13, 2024

@Bilge you can use this configuration to see what bash behaves like in Windows Terminal:

{
    "commandline": "%PROGRAMFILES%/Git/usr/bin/bash.exe -i -l",
    "guid": "{00000000-0000-0000-ba54-000000000002}",
    "icon": "%PROGRAMFILES%/Git/mingw64/share/git/git-for-windows.ico",
    "name": "Bash",
    "startingDirectory": "%USERPROFILE%"
}

Git Bash is actually mintty that runs this bash version inside as a packaged entity.

That said, I don't have the above issue with my theme.

image

I can reproduce this using Git's Bash with powerlevel10k_rainbow.omp.json, but not on native bash. The \ character in the path is what's causing it, but that's escaped. So this is a bug in Git Bash apparently.

image

You can fix it by adjusting the configuration for the path segment to use a forward slash as path separator "folder_separator_icon": "/".

image

I'll see if I can add that as the native behaviour and hopefully that's the last of Git Bash' shenanigans. I do promote the use of nushell when you dislike PowerShell on Windows, that's a really, really good shell that integrates natively with Windows unlike Git Bash.

from oh-my-posh.

Bilge avatar Bilge commented on September 13, 2024

I guess changing folder_separator_icon is an OK workaround, but perhaps a bug should be filed with git-for-windows/git?

from oh-my-posh.

JanDeDobbeleer avatar JanDeDobbeleer commented on September 13, 2024

@Bilge I can reproduce the issue on bash anywhere using "folder_separator_icon": "\\" so it's some sort of magical bash issue. The \ character is escaped, yet it has this strange side effect. I can definitely make sure this will always fallback to / on bash, but weird nonetheless.

from oh-my-posh.

hungnguyen1503 avatar hungnguyen1503 commented on September 13, 2024

Hi @JanDeDobbeleer,

I have a problem after using the latest version. Could you please support me to fix it?
image

from oh-my-posh.

hungnguyen1503 avatar hungnguyen1503 commented on September 13, 2024

Hi @JanDeDobbeleer,
It was fixed, thank you so much.

from oh-my-posh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.