Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSCode shell integration disables posh-git prompt #931

Open
Jawz84 opened this issue Nov 1, 2022 · 5 comments
Open

VSCode shell integration disables posh-git prompt #931

Jawz84 opened this issue Nov 1, 2022 · 5 comments

Comments

@Jawz84
Copy link

Jawz84 commented Nov 1, 2022

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.

@dahlbyk
Copy link
Owner

dahlbyk commented Nov 1, 2022

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.

@pavel-zhigulin
Copy link

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!

@0ryant
Copy link

0ryant commented Dec 18, 2023

thanks for the workaround :)

@martixy
Copy link

martixy commented Apr 21, 2024

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

@dahlbyk
Copy link
Owner

dahlbyk commented Apr 22, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants