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

Using transparent background in transient_prompt doesn't work without initial transparent cell #3260

Closed heaths closed 1 year ago

heaths commented 1 year ago

Code of Conduct

What happened?

In pwsh on Ubuntu 22.04 in WSL2 using Windows Terminal, if I don't use a character that shows part of the terminal profile's background, the rest of the line shows the initial background color. For example,

transient_prompt:
  background: transparent
  template: " <p:white,p:gray>{{ path .PWD .Folder }} </><p:gray,transparent>></> "

...shows what I'd expect: image

However, if the initial cell on that line is not showing the background color of the terminal profile, the rest of the line uses the background color I initial set in the template:

transient_prompt:
  background: transparent
-  template: " <p:white,p:gray>{{ path .PWD .Folder }} </><p:gray,transparent>></> "
+  template: "<p:white,p:gray>{{ path .PWD .Folder }} </><p:gray,transparent>></> "

image

Theme

Custom, using the transient_prompt shown above as well as a few variations, like a Powerline font uses an "arrow" char that shows the terminal profile background initially.

What OS are you seeing the problem on?

Windows, Linux

Which shell are you using?

bash, powershell

Log output

Version: 12.31.1

Segments:

ConsoleTitle(true)   -   1 ms - pwsh in oh-my-posh
shell(true)          -   0 ms -  PS 
executiontime(false) -   0 ms - 
session(true)        -   0 ms -  heaths 
path(true)           -   3 ms -   ]8;;file://wsl.localhost/Ubuntu-22.04/home/heaths/.config/oh-my-posh\~/../oh-my-posh]8;;\ 
git(false)           -   2 ms - 
root(false)          -   0 ms - 
exit(false)          -   0 ms - 

Run duration: 13.481245ms

Cache path: /home/heaths/.cache/oh-my-posh

Config path: /home/heaths/.config/oh-my-posh/theme.omp.yml

Logs:

2022/12/28 02:54:22 Getenv

2022/12/28 02:54:22 Getenv: 18.1µs, args: XDG_CACHE_HOME
2022/12/28 02:54:22 CachePath: 39.7µs
2022/12/28 02:54:22 Getenv
/home/heaths/.config/oh-my-posh/theme.omp.yml
2022/12/28 02:54:22 Getenv: 6.599µs, args: POSH_THEME
2022/12/28 02:54:22 resolveConfigPath: 11.299µs
2022/12/28 02:54:22 Init: 2.063061ms
2022/12/28 02:54:22 Flags: 100ns
2022/12/28 02:54:22 config.loadConfig: 1.934564ms
2022/12/28 02:54:22 Flags: 100ns
2022/12/28 02:54:22 Getenv

2022/12/28 02:54:22 Getenv: 3.7µs, args: OMP_CACHE_DISABLED
2022/12/28 02:54:22 Root: 2µs
2022/12/28 02:54:22 Shell
process name: pwsh
2022/12/28 02:54:22 Shell: 955.082µs
2022/12/28 02:54:22 ErrorCode: 100ns
2022/12/28 02:54:22 Getenv
Ubuntu-22.04
2022/12/28 02:54:22 Getenv: 2.2µs, args: WSL_DISTRO_NAME
2022/12/28 02:54:22 IsWsl: 4.1µs
2022/12/28 02:54:22 GOOS: 200ns
2022/12/28 02:54:22 Pwd
/home/heaths/.config/oh-my-posh
2022/12/28 02:54:22 Pwd: 13.799µs
2022/12/28 02:54:22 GOOS: 100ns
2022/12/28 02:54:22 GOOS: 0s
2022/12/28 02:54:22 GOOS: 100ns
2022/12/28 02:54:22 GOOS: 100ns
2022/12/28 02:54:22 GOOS: 100ns
2022/12/28 02:54:22 GOOS: 100ns
2022/12/28 02:54:22 GOOS: 0s
2022/12/28 02:54:22 GOOS: 100ns
2022/12/28 02:54:22 GOOS: 100ns
2022/12/28 02:54:22 GOOS: 0s
2022/12/28 02:54:22 GOOS: 0s
2022/12/28 02:54:22 GOOS: 100ns
2022/12/28 02:54:22 User
heaths
2022/12/28 02:54:22 User: 1.7µs
2022/12/28 02:54:22 Host
heathsp6
2022/12/28 02:54:22 Host: 4.7µs
2022/12/28 02:54:22 GOOS: 99ns
2022/12/28 02:54:22 TemplateCache: 1.103879ms
2022/12/28 02:54:22 Flags: 300ns
2022/12/28 02:54:22 Pwd
/home/heaths/.config/oh-my-posh
2022/12/28 02:54:22 Pwd: 4.599µs
2022/12/28 02:54:22 GOOS: 100ns
2022/12/28 02:54:22 Shell: 400ns
2022/12/28 02:54:22 Flags: 100ns
2022/12/28 02:54:22 TemplateCache: 300ns
2022/12/28 02:54:22 TemplateCache: 400ns
2022/12/28 02:54:22 Shell: 100ns
2022/12/28 02:54:22 Pwd
/home/heaths/.config/oh-my-posh
2022/12/28 02:54:22 Pwd: 3.5µs
2022/12/28 02:54:22 GOOS: 100ns
2022/12/28 02:54:22 ExecutionTime: 100ns
2022/12/28 02:54:22 Pwd
/home/heaths/.config/oh-my-posh
2022/12/28 02:54:22 Pwd: 2.5µs
2022/12/28 02:54:22 GOOS: 0s
2022/12/28 02:54:22 Getenv

2022/12/28 02:54:22 Getenv: 1.4µs, args: SSH_CONNECTION
2022/12/28 02:54:22 Getenv

2022/12/28 02:54:22 Getenv: 1.2µs, args: SSH_CLIENT
2022/12/28 02:54:22 TemplateCache: 100ns
2022/12/28 02:54:22 TemplateCache: 300ns
2022/12/28 02:54:22 Shell: 200ns
2022/12/28 02:54:22 Pwd
/home/heaths/.config/oh-my-posh
2022/12/28 02:54:22 Pwd: 3.6µs
2022/12/28 02:54:22 GOOS: 100ns
2022/12/28 02:54:22 Pwd
/home/heaths/.config/oh-my-posh
2022/12/28 02:54:22 Pwd: 11.7µs
2022/12/28 02:54:22 Shell: 200ns
2022/12/28 02:54:22 Flags: 100ns
2022/12/28 02:54:22 GOOS: 0s
2022/12/28 02:54:22 PathSeparator: 200ns
2022/12/28 02:54:22 GOOS: 100ns
2022/12/28 02:54:22 GOOS: 100ns
2022/12/28 02:54:22 GOOS: 200ns
2022/12/28 02:54:22 GOOS: 0s
2022/12/28 02:54:22 PathSeparator: 100ns
2022/12/28 02:54:22 PathSeparator: 100ns
2022/12/28 02:54:22 GOOS: 100ns
2022/12/28 02:54:22 GOOS: 100ns
2022/12/28 02:54:22 PathSeparator: 100ns
2022/12/28 02:54:22 GOOS: 0s
2022/12/28 02:54:22 GOOS: 0s
2022/12/28 02:54:22 PathSeparator: 100ns
2022/12/28 02:54:22 GOOS: 0s
2022/12/28 02:54:22 GOOS: 0s
2022/12/28 02:54:22 PathSeparator: 100ns
2022/12/28 02:54:22 PathSeparator: 0s
2022/12/28 02:54:22 PathSeparator: 0s
2022/12/28 02:54:22 PathSeparator: 100ns
2022/12/28 02:54:22 PathSeparator: 0s
2022/12/28 02:54:22 Pwd
/home/heaths/.config/oh-my-posh
2022/12/28 02:54:22 Pwd: 1.3µs
2022/12/28 02:54:22 Getenv
Ubuntu-22.04
2022/12/28 02:54:22 Getenv: 1.9µs, args: WSL_DISTRO_NAME
2022/12/28 02:54:22 IsWsl: 3.6µs
2022/12/28 02:54:22 RunCommand
//wsl.localhost/Ubuntu-22.04/home/heaths/.config/oh-my-posh
2022/12/28 02:54:22 RunCommand: 2.221358ms, args: wslpath -m /home/heaths/.config/oh-my-posh
2022/12/28 02:54:22 StackCount: 400ns
2022/12/28 02:54:22 DirIsWritable: 14.299µs, args: /home/heaths/.config/oh-my-posh
2022/12/28 02:54:22 TemplateCache: 400ns
2022/12/28 02:54:22 TemplateCache: 500ns
2022/12/28 02:54:22 Shell: 500ns
2022/12/28 02:54:22 Pwd
/home/heaths/.config/oh-my-posh
2022/12/28 02:54:22 Pwd: 6.9µs
2022/12/28 02:54:22 GOOS: 100ns
2022/12/28 02:54:22 Getenv
Ubuntu-22.04
2022/12/28 02:54:22 Getenv: 2µs, args: WSL_DISTRO_NAME
2022/12/28 02:54:22 IsWsl: 15.6µs
2022/12/28 02:54:22 FileContent
5.15.79.1-microsoft-standard-WSL2

2022/12/28 02:54:22 FileContent: 88.498µs, args: /proc/sys/kernel/osrelease
2022/12/28 02:54:22 IsWsl2: 109.198µs
2022/12/28 02:54:22 Pwd
/home/heaths/.config/oh-my-posh
2022/12/28 02:54:22 Pwd: 1.3µs
2022/12/28 02:54:22 RunCommand
//wsl.localhost/Ubuntu-22.04/home/heaths/.config/oh-my-posh
2022/12/28 02:54:22 RunCommand: 1.862365ms, args: wslpath -m /home/heaths/.config/oh-my-posh
2022/12/28 02:54:22 GOOS: 100ns
2022/12/28 02:54:22 CommandPath
/usr/bin/git
2022/12/28 02:54:22 CommandPath: 85.498µs, args: git
2022/12/28 02:54:22 HasCommand: 87.498µs, args: git
2022/12/28 02:54:22 Pwd
/home/heaths/.config/oh-my-posh
2022/12/28 02:54:22 Pwd: 1.5µs
2022/12/28 02:54:22 HasParentFilePath
stat /.git: no such file or directory
2022/12/28 02:54:22 HasParentFilePath: 122.798µs, args: .git
2022/12/28 02:54:22 Pwd
/home/heaths/.config/oh-my-posh
2022/12/28 02:54:22 Pwd: 2µs
2022/12/28 02:54:22 GOOS: 100ns
2022/12/28 02:54:22 Root: 1.5µs
2022/12/28 02:54:22 Pwd
/home/heaths/.config/oh-my-posh
2022/12/28 02:54:22 Pwd: 1.4µs
2022/12/28 02:54:22 GOOS: 100ns
2022/12/28 02:54:22 ErrorCode: 300ns
2022/12/28 02:54:22 ErrorCode: 0s
2022/12/28 02:54:22 Getenv

2022/12/28 02:54:22 Getenv: 1.9µs, args: XDG_CACHE_HOME
2022/12/28 02:54:22 CachePath: 14.6µs
2022/12/28 02:54:22 Flags: 100ns
heaths commented 1 year ago

To note, a secondary_prompt does not show the initial background color from the first cell e.g.,

secondary_prompt:
  background: transparent
  template: "<p:white,p:gray> </><p:gray,transparent></> "

Shows: image

Before filing this, I experimented with a few variations and figured it might just be how VT100 sequences are supported, but that this works with the secondary_prompt makes me wonder if there is something that, perhaps, could be done to resolve this issue.

JanDeDobbeleer commented 1 year ago

@heaths I'll check if we properly restore the colors. Although I don't think we have a different implementation for transient and secondary.

JanDeDobbeleer commented 1 year ago

@heaths I have a similar config for my transient prompt and I can't reproduce this at all on macOS using iTerm2. Does this happen for bash as well or only PowerShell?

EDIT: sam for PowerShell Windows, works.

heaths commented 1 year ago

Interesting. It only happens on pwsh in Ubuntu under WSL2. Running in bare Windows it works just fine: image

There's nothing in my PSReadLine options that would account for this, but clearly I have some more digging to do.

JanDeDobbeleer commented 1 year ago

@heaths is your PSReadLine up-to-date there?

heaths commented 1 year ago

Oddly enough, though I have pwsh 7.3.1 in both places that ships with PSReadline 2.2.6, my Windows module is still 2.2.2 (where this works). I did upgrade to 2.2.6 (turns out 2.2.2 was installed per-user) and it works fine.

heaths commented 1 year ago

Given this works on Windows, I'll investigate further why it doesn't work as expected under WSL2. Almost definitely not a problem with OMP, though. I will comment back here if I find otherwise, but that's highly doubtful. Thanks for the pointers!

heaths commented 1 year ago

FWIW, whatever is causing this does appear to be using the color of the first cell in that line: image

(Posting here in case someone else runs into this and has some ideas)

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