JanDeDobbeleer / oh-my-posh

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

Seems oh-my-posh does not work with latest PowerShell core (pwsh) #1501

Closed yekanchi closed 2 years ago

yekanchi commented 2 years ago

Code of Conduct

What happened?

while oh-my-posh works fine in powershell 6 on my pc, i encounterd a problem with latest pwsh in two of my computers that it's like it have some problem with colors in all of the themes.

reproduce steps:

image

but when run oh-my-posh it works for a single line as expected:

image

Theme

default

What OS are you seeing the problem on?

Windows

Which shell are you using?

No response

Log output

Version: 6.39.0

Segments:

ConsoleTitle(true) -   0 ms -
session(true)  -   0 ms - yekanchi@mypc 
path(true)     -   0 ms -   pwsh 
git(false)     -  16 ms -
battery(false) -   2 ms -
node(false)    -   1 ms -
shell(true)    -   0 ms -  ﲵ pwsh 
root(false)    -   0 ms -
text(true)     -   0 ms -  NO CONFIG 
exit(true)     -   0 ms -   

Run duration: 23.3635ms

Logs:

2021/12/25 15:12:31 debug: getenv
C:\Users\m.talebi\AppData\Local
2021/12/25 15:12:31 getenv duration: 55.2µs, args: LOCALAPPDATA
2021/12/25 15:12:31 getCachePath duration: 170.6µs, args:
2021/12/25 15:12:31 getArgs duration: 0s, args:
2021/12/25 15:12:31 getArgs duration: 0s, args:
2021/12/25 15:12:31 getShellName duration: 9.4974ms, args:
2021/12/25 15:12:31 debug: getenv

2021/12/25 15:12:31 getenv duration: 0s, args: OMP_CACHE_DISABLED
2021/12/25 15:12:31 isRunningAsRoot duration: 0s, args:
2021/12/25 15:12:31 getcwd duration: 506.1µs, args:
2021/12/25 15:12:31 getPathSeperator duration: 0s, args:
2021/12/25 15:12:31 getPathSeperator duration: 0s, args:
2021/12/25 15:12:31 getPathSeperator duration: 0s, args:
2021/12/25 15:12:31 getPathSeperator duration: 0s, args:
2021/12/25 15:12:31 getPathSeperator duration: 0s, args:
2021/12/25 15:12:31 getPathSeperator duration: 0s, args:
2021/12/25 15:12:31 getShellName duration: 0s, args:
2021/12/25 15:12:31 getCurrentUser duration: 0s, args:
2021/12/25 15:12:31 getHostName duration: 0s, args:
2021/12/25 15:12:31 getcwd duration: 0s, args:
2021/12/25 15:12:31 debug: getenv

2021/12/25 15:12:31 getenv duration: 0s, args: SSH_CONNECTION
2021/12/25 15:12:31 debug: getenv

2021/12/25 15:12:31 getenv duration: 0s, args: SSH_CLIENT
2021/12/25 15:12:31 getCurrentUser duration: 0s, args:
2021/12/25 15:12:31 getRuntimeGOOS duration: 0s, args:
2021/12/25 15:12:31 getHostName duration: 0s, args:
2021/12/25 15:12:31 debug: getenv

2021/12/25 15:12:31 getenv duration: 0s, args: POSH_SESSION_DEFAULT_USER
2021/12/25 15:12:31 getcwd duration: 0s, args:
2021/12/25 15:12:31 getcwd duration: 0s, args:
2021/12/25 15:12:31 getArgs duration: 0s, args:
2021/12/25 15:12:31 getRuntimeGOOS duration: 0s, args:
2021/12/25 15:12:31 getRuntimeGOOS duration: 0s, args:
2021/12/25 15:12:31 getPathSeperator duration: 0s, args:
2021/12/25 15:12:31 getPathSeperator duration: 0s, args:
2021/12/25 15:12:31 getPathSeperator duration: 0s, args:
2021/12/25 15:12:31 getPathSeperator duration: 0s, args:
2021/12/25 15:12:31 getPathSeperator duration: 0s, args:
2021/12/25 15:12:31 getPathSeperator duration: 0s, args:
2021/12/25 15:12:31 getPathSeperator duration: 0s, args:
2021/12/25 15:12:31 getRuntimeGOOS duration: 0s, args:
2021/12/25 15:12:31 stackCount duration: 0s, args:
2021/12/25 15:12:31 getcwd duration: 0s, args:
2021/12/25 15:12:31 getRuntimeGOOS duration: 0s, args:
2021/12/25 15:12:31 error: hasCommand
exec: "git.exe": executable file not found in %PATH%
2021/12/25 15:12:31 hasCommand duration: 16.2379ms, args: git.exe
2021/12/25 15:12:31 getcwd duration: 0s, args:
2021/12/25 15:12:31 getBatteryInfo duration: 2.9929ms, args:
2021/12/25 15:12:31 getcwd duration: 0s, args:
2021/12/25 15:12:31 getcwd duration: 0s, args:
2021/12/25 15:12:31 getcwd duration: 0s, args:
2021/12/25 15:12:31 getPathSeperator duration: 0s, args:
2021/12/25 15:12:31 hasFiles duration: 997.6µs, args: *.js
2021/12/25 15:12:31 getcwd duration: 0s, args:
2021/12/25 15:12:31 getPathSeperator duration: 0s, args:
2021/12/25 15:12:31 hasFiles duration: 997.4µs, args: *.ts
2021/12/25 15:12:31 getcwd duration: 0s, args:
2021/12/25 15:12:31 getPathSeperator duration: 0s, args:
2021/12/25 15:12:31 hasFiles duration: 0s, args: package.json
2021/12/25 15:12:31 getcwd duration: 0s, args:
2021/12/25 15:12:31 getPathSeperator duration: 0s, args:
2021/12/25 15:12:31 hasFiles duration: 0s, args: .nvmrc
2021/12/25 15:12:31 getcwd duration: 0s, args:
2021/12/25 15:12:31 getPathSeperator duration: 0s, args:
2021/12/25 15:12:31 hasFiles duration: 0s, args: pnpm-workspace.yaml
2021/12/25 15:12:31 getcwd duration: 0s, args:
2021/12/25 15:12:31 getPathSeperator duration: 0s, args:
2021/12/25 15:12:31 hasFiles duration: 0s, args: .pnpmfile.cjs
2021/12/25 15:12:31 getcwd duration: 0s, args:
2021/12/25 15:12:31 getPathSeperator duration: 0s, args:
2021/12/25 15:12:31 hasFiles duration: 0s, args: .npmrc
2021/12/25 15:12:31 getcwd duration: 0s, args:
2021/12/25 15:12:31 getShellName duration: 0s, args:
2021/12/25 15:12:31 getcwd duration: 0s, args:
2021/12/25 15:12:31 isRunningAsRoot duration: 0s, args:
2021/12/25 15:12:31 getcwd duration: 0s, args:
2021/12/25 15:12:31 isRunningAsRoot duration: 0s, args:
2021/12/25 15:12:31 getcwd duration: 0s, args:
2021/12/25 15:12:31 getPathSeperator duration: 0s, args:
2021/12/25 15:12:31 getPathSeperator duration: 0s, args:
2021/12/25 15:12:31 getPathSeperator duration: 0s, args:
2021/12/25 15:12:31 getPathSeperator duration: 0s, args:
2021/12/25 15:12:31 getPathSeperator duration: 0s, args:
2021/12/25 15:12:31 getPathSeperator duration: 0s, args:
2021/12/25 15:12:31 getShellName duration: 0s, args:
2021/12/25 15:12:31 getCurrentUser duration: 0s, args:
2021/12/25 15:12:31 getHostName duration: 0s, args:
2021/12/25 15:12:31 getcwd duration: 0s, args:
2021/12/25 15:12:31 lastErrorCode duration: 0s, args:
JanDeDobbeleer commented 2 years ago

@yekanchi the latest version of Powershell has a change in colors. See here for more information. This is not an issue with oh-my-posh.

JanDeDobbeleer commented 2 years ago

@yekanchi also see this issue for more information.

yekanchi commented 2 years ago

i'm using windows terminal, and tried set $PSStyle.OutputRendering="ANSI" and $env:TERM="xterm" but it does not work. it works fine in vsCode terminal but in the windows-terminal it shows not colors. even the $PSStyle command output has no colors. so it seems it's a windows terminal issue or pwsh issue.

but why the oh-my-posh command show's the correct output colors?

JanDeDobbeleer commented 2 years ago

@yekanchi there's probably a difference in how Powershell renders ANSI in standardout vs prompt. That's a separate function so there might be additional logic. I would open an issue at pwsh, I'm curious to understand what's exactly causing it.

Now that I think about it, is your PSReadline version up to date?

yekanchi commented 2 years ago

@yekanchi there's probably a difference in how Powershell renders ANSI in standardout vs prompt. That's a separate function so there might be additional logic. I would open an issue at pwsh, I'm curious to understand what's exactly causing it.

Now that I think about it, is your PSReadline version up to date?

My PSReadline Version is 2.2 beta4 image

yekanchi commented 2 years ago

update: on vsCode these two lines:

$env:TERM="xterm"
$PSStyle.OutputRendering=2;

added to the pwsh profile fixes the issue for the vsCode terminal, but very the same shell and profile(pwsh) does not show colors in windows terminal or cmd.exe terminal

JanDeDobbeleer commented 2 years ago

@yekanchi works perfectly for me on 7.2.1 (Windows 11) with the following setting:

$PSStyle.OutputRendering=Host

$env:TERM isn't set. I can't reproduce this, and it's for sure an issue with your env. can you go and ask our friends at Powershell what needs to be done?

AlexMilender commented 2 years ago

@yekanchi I had a similar issue #2963 Solution: Removing System Environment Variable "Term : dumb" resolved my issue.

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