Spaces added to prompt on shell launch (PowerShell/pwsh) #11507

Open
opened 2026-01-31 02:49:36 +00:00 by claunia · 0 comments
Owner

Originally created by @yooakim on GitHub (Nov 20, 2020).

Originally assigned to: @DHowett on GitHub.

Environment

Win32NT 10.0.19042.0 Microsoft Windows NT 10.0.19042.0
Windows Terminal Version: 1.4.3141.0

https://github.com/justjanne/powerline-go

Steps to reproduce

Add the following to your PowerShell $PROFILE (adjust the path to the powerline-go exectuable to your local environment)

Function global:prompt {
    $pwd = $ExecutionContext.SessionState.Path.CurrentLocation
    $startInfo = New-Object System.Diagnostics.ProcessStartInfo
    $startInfo.FileName = "$ENV:OneDriveConsumer\Util\powerline-go.exe"
    $startInfo.Arguments = "-shell bare"
    $startInfo.Environment["TERM"] = "xterm-256color"
    $startInfo.CreateNoWindow = $true
    $startInfo.StandardOutputEncoding = [System.Text.Encoding]::UTF8
    $startInfo.RedirectStandardOutput = $true
    $startInfo.UseShellExecute = $false
    $startInfo.WorkingDirectory = $pwd
    $process = New-Object System.Diagnostics.Process
    $process.StartInfo = $startInfo
    $process.Start() | Out-Null
    $standardOut = $process.StandardOutput.ReadToEnd()
    $process.WaitForExit()
    $standardOut
}

Start a PowerShell (classic) or PowerShell terminal window via Windows Terminal. The first time the prompt function is called there are spaces inserted between the different prompt parts. Pressing Enter makes these disappear and the prompt works fine.

If I use the same profile without Windows Terminal launching PowerShell.exe directly it works fine. So I suspect this is related to Windows Terminal.

Here's an animated GIF that shows what is going on:

powerline-spaces

Expected behavior

I expect to see the prompt formatted correctly as follows:
powerline-go-expected

Actual behavior

This is what the prompt looks like when the PowerShell is first started:

powerline-go-actual
Originally created by @yooakim on GitHub (Nov 20, 2020). Originally assigned to: @DHowett on GitHub. # Environment ```none Win32NT 10.0.19042.0 Microsoft Windows NT 10.0.19042.0 Windows Terminal Version: 1.4.3141.0 https://github.com/justjanne/powerline-go ``` # Steps to reproduce Add the following to your PowerShell $PROFILE (adjust the path to the powerline-go exectuable to your local environment) ```PowerShell Function global:prompt { $pwd = $ExecutionContext.SessionState.Path.CurrentLocation $startInfo = New-Object System.Diagnostics.ProcessStartInfo $startInfo.FileName = "$ENV:OneDriveConsumer\Util\powerline-go.exe" $startInfo.Arguments = "-shell bare" $startInfo.Environment["TERM"] = "xterm-256color" $startInfo.CreateNoWindow = $true $startInfo.StandardOutputEncoding = [System.Text.Encoding]::UTF8 $startInfo.RedirectStandardOutput = $true $startInfo.UseShellExecute = $false $startInfo.WorkingDirectory = $pwd $process = New-Object System.Diagnostics.Process $process.StartInfo = $startInfo $process.Start() | Out-Null $standardOut = $process.StandardOutput.ReadToEnd() $process.WaitForExit() $standardOut } ``` Start a PowerShell (classic) or PowerShell terminal window via Windows Terminal. The first time the prompt function is called there are spaces inserted between the different prompt parts. Pressing `Enter` makes these disappear and the prompt works fine. If I use the same profile without Windows Terminal launching PowerShell.exe directly it works fine. So I suspect this is related to Windows Terminal. Here's an animated GIF that shows what is going on: ![powerline-spaces](https://user-images.githubusercontent.com/862546/99776375-013ac800-2b11-11eb-8c05-48a7c3f953ed.gif) # Expected behavior I expect to see the prompt formatted correctly as follows: <img width="720" alt="powerline-go-expected" src="https://user-images.githubusercontent.com/862546/99776755-9c33a200-2b11-11eb-9cbe-441844632c51.png"> # Actual behavior This is what the prompt looks like when the PowerShell is first started: <img width="720" alt="powerline-go-actual" src="https://user-images.githubusercontent.com/862546/99776660-70182100-2b11-11eb-963f-c907c4c9ffa0.png">
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#11507