posh-git
posh-git copied to clipboard
Importing posh-git messes up the PowerShell layout
System Details
- posh-git version/path: 1.1.0
- PowerShell version: 5.1
- Git version: 2.35.1.windows.2
- Operating system name and version: Windows 10
Issue Description
I'm importing the posh-git module in my profile, but it messes up the layout of my prompt. If I comment out the following:
Import-Module posh-git
from my profile, my powershell looks as expected. However if I leave it in, it looks like this:
What's going wrong here?
It's hard to say without knowing more about how your profile is set up. Try this: powershell.exe -NoProfile
which will start PowerShell without executing any profile script. Once PowerShell starts up, is the prompt still messed up? If it is, try executing this in that console: Import-Module posh-git; $global:GitPromptSettings.AnsiConsole = $false
to see if that fixes the prompt.
It's hard to say without knowing more about how your profile is set up. Try this:
powershell.exe -NoProfile
which will start PowerShell without executing any profile script. Once PowerShell starts up, is the prompt still messed up? If it is, try executing this in that console:Import-Module posh-git; $global:GitPromptSettings.AnsiConsole = $false
to see if that fixes the prompt.
When I run that, PowerShell loads as expected:
Even when I load the rest of my profile it looks as expected, only the Import-Module posh-git
line seems to make it weird.
When you import the posh-git
module, it will install a prompt function that displays Git info when you're CD'd into a Git repo e.g.:

It appears that your console is not set up to support ANSI VT sequences, which posh-git uses if it detects that they're supported i.e. if $host.UI.SupportsVirtualTerminal
returns True
. What console are you using? The Windows default console, Windows Terminal, ConEmu, Cmder, ??
BTW by setting $global:GitPromptSettings.AnsiConsole = $false
after you execute Import-Module posh-git
in your profile script, you're telling posh-git
to ignore the result of $host.UI.SupportsVirtualTerminal
and NOT use VT sequences for coloring text.
Assuming PS indicates that it does support VT sequences, try this:
"$([char]27)[32mThis should be Green$([char]27)[0m"
Does that display the text in Green?
When you import the
posh-git
module, it will install a prompt function that displays Git info when you're CD'd into a Git repo e.g.:![]()
It appears that your console is not set up to support ANSI VT sequences, which posh-git uses if it detects that they're supported i.e. if
$host.UI.SupportsVirtualTerminal
returnsTrue
. What console are you using? The Windows default console, Windows Terminal, ConEmu, Cmder, ??BTW by setting
$global:GitPromptSettings.AnsiConsole = $false
after you executeImport-Module posh-git
in your profile script, you're tellingposh-git
to ignore the result of$host.UI.SupportsVirtualTerminal
and NOT use VT sequences for coloring text.Assuming PS indicates that it does support VT sequences, try this:
"$([char]27)[32mThis should be Green$([char]27)[0m"
Does that display the text in Green?
I've tested this with both the Windows Terminal and the default Powershell. Both display the same behavior.
Adding the line $global:GitPromptSettings.AnsiConsole = $false
does solve the problem, so thanks for that!
When I run the other line, it does display as green, both with and without importing posh-git and applying the other line:
Edit; just read that you already suggested that in the previous comment, my bad haha
My guess is that there is something else in one of your profile scripts that is interfering with posh-git
. Can you post the output of the following command? This will show the contents of all your profile scripts.
$profile.psobject.Properties.Value |
Where-Object {Test-Path $_} |
Foreach-Object {"$('-'*78)`nContents of ${_}:`n$(Get-Content $_ -ea ignore)`n$('-'*78)"}
By the way I had this same problem on MacOS. It started when I updated posh-git to 1.1 from 1.0. Afterwards my prompt looked like this:
Text: ""Text: "", ANSI: "
e[93me[39m"Text: "~"Text: "", ANSI: "
e[93me[39m"Text: ""Text: ">
The problem was that my profile.ps1 file still imported the 1.0.0 version. Updating it to import 1.1.0 corrected the issue.
$global:GitPromptSettings.AnsiConsole = $false
Same issue and this works for me