posh-git
posh-git copied to clipboard
VSCode shell integration disables posh-git prompt
System Details
- posh-git version/path: 1.1.0 ~\Documents\PowerShell\Modules\posh-git\1.1.0
- PowerShell version: 7.2.7
- Git version: 2.38.1.windows.1
- Operating system name and version: Microsoft Windows NT 10.0.19045.0
Issue Description
I am experiencing a problem with VSCode Terminal Shell Integration, the new feature that shows color coded dots in the margin for successfull/failed command executions. Read more here. It prevents the prompt from being adapted by Posh-Git. So on loading of Posh-Git, the prompt stays the same. (posh-git does load, and stuff like branch name completion does work, it's just the apdaptation of the prompt function that fails.)
I realize this is not a problem of Posh-Git per se. I just wanted to make you aware of this.
Work-around
I found a work-around by setting terminal.integrated.shellIntegration.enabled
to false
, and restarting the terminal.
Remarks
What is maybe interesting, is that you can see the injected script that VSCode uses for the decorations etc by running code (code --locate-shell-integration-path pwsh)
. I wouldn't know how to adapt that so that it displays posh-git prompt style too.
Try swapping Import-Module posh-git
after what VS Code injects. Does posh-git prompt win, but the VS Code feature breaks?
Looks like there are custom escape sequences, which could either be customized or built into posh-git.
I have the same problem. Even when import posh-git after loading of the terminal, there is no posh-git prompt available in terminal.
Thanks for the workaround. It works!
thanks for the workaround :)
This might be unrelated to OP, but I landed here having posh-git in ~\Documents\PowerShell\Modules\posh-git\1.1.0 and wondering why it's not showing up in my PS7/vscode shell, and so others will probably arrive here for the same reasons. For those people:
Each shell is its own environment.
For each shell you want posh-git in, run
PowerShellGet\Install-Module posh-git -Scope CurrentUser -Force
and Add-PoshGitToProfile
For each shell you want posh-git in, run
PowerShellGet\Install-Module posh-git -Scope CurrentUser -Force
andAdd-PoshGitToProfile
Install-Module
installs to a different location for Windows PowerShell and PowerShell Core, but once installed for both you shouldn't need to reinstall.
Instead of installing for each shell you can also try Add-PoshGitToProfile -AllHosts
, which should be run for the default host, VS Code host, etc.