posh-git icon indicating copy to clipboard operation
posh-git copied to clipboard

VSCode shell integration disables posh-git prompt

Open Jawz84 opened this issue 2 years ago • 5 comments

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.

Jawz84 avatar Nov 01 '22 08:11 Jawz84

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.

dahlbyk avatar Nov 01 '22 11:11 dahlbyk

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!

pavel-zhigulin avatar May 28 '23 22:05 pavel-zhigulin

thanks for the workaround :)

0ryant avatar Dec 18 '23 10:12 0ryant

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

martixy avatar Apr 21 '24 10:04 martixy

For each shell you want posh-git in, run PowerShellGet\Install-Module posh-git -Scope CurrentUser -Force and Add-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.

dahlbyk avatar Apr 22 '24 14:04 dahlbyk