Background color goes beyond prompt after program execution
See original GitHub issueSteps to reproduce
Invoke-Module 'PSReadLine'
function OnViModeChange {
if ($args[0] -eq 'Command') {
$script:vicolor = [ConsoleColor]::Red
} else {
$script:vicolor = [ConsoleColor]::Green
}
[Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt()
}
Set-PSReadLineOption -EditMode Vi
Set-PSReadLineOption -ExtraPromptLineCount 2
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
Set-PSReadLineOption -ViModeIndicator Script -ViModeChangeHandler $Function:OnViModeChange
function Prompt {
$Prompt = Write-Prompt "`n"
$Prompt += Write-Prompt "`n DEBUG" -BackgroundColor $script:vicolor
$Prompt += Write-Prompt ">" -ForegroundColor $script:vicolor
if ($Prompt) { "$Prompt " } else { " " }
}
Expected behavior
Background color stops at the last character of the prompt.
Actual behavior
When I run a program (say "some_app.exe") in pwsh and quit, the background color goes beyond the prompt as shown:
Environment data
Name Value
---- -----
PSVersion 7.1.1
PSEdition Core
GitCommitId 7.1.1
OS Microsoft Windows 10.0.19042
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (4 by maintainers)
Top Results From Across the Web
prompt and change background color in a loop with native ...
1 Answer. You can loop until value of the prompt entered is null. However you won't see the color change until after you...
Read more >How did I change color scheme of command prompt?
Navigate to HKEY_CURRENT_USER\Software\Microsoft\Command Processor and check ... the background colour, and the second one the text colour.
Read more >Overwrite bg color of zsh prompt
I'm using zsh with prompt fade , I do not have oh-my-zsh installed. My terminal background is dark blue, not black, but the...
Read more >Command line CMD background change color, but how ...
1.) Change the background color and foreground color in the CMD! The first hexadecimal digit defines the background of the prompt, the second ......
Read more >Background colors on segments not rendering in MacOS ...
Steps to Reproduce. First, create example.json with the theme from the docs. Note it has a foreground and background color. Theme:.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for your effort! However, it seems that this issue starts to occur when the prompt hits the last line of the terminal (I’m using WT preview
1.16.3463.0
):I tried running
Write-Warning foo; 'bar'
as mentioned in #14506, but it did not reproduce my issue. Thanks though.