Skip to content

Commit 43086a2

Browse files
authored
Merge pull request #425 from dahlbyk/old-posh-git-prompt
Ignore pre-0.7 posh-git prompt
2 parents bdbca1c + 675920d commit 43086a2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/posh-git.psm1

+8
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ else {
3838
$poshGitPromptScriptBlock = $null
3939

4040
$currentPromptDef = if ($funcInfo = Get-Command prompt -ErrorAction SilentlyContinue) { $funcInfo.Definition }
41+
42+
# If prompt matches pre-0.7 posh-git prompt, ignore it
43+
$collapsedLegacyPrompt = '$realLASTEXITCODE = $LASTEXITCODE;Write-Host($pwd.ProviderPath) -nonewline;Write-VcsStatus;$global:LASTEXITCODE = $realLASTEXITCODE;return "> "'
44+
if ($currentPromptDef -and (($collapsedLegacyPrompt.Trim() -replace '[\r\n\t]+\s*',';') -eq $collapsedLegacyPrompt)) {
45+
Write-Warning 'Replacing old posh-git prompt. Did you copy profile.example.ps1 into $PROFILE?'
46+
$currentPromptDef = $null
47+
}
48+
4149
if (!$currentPromptDef) {
4250
# HACK: If prompt is missing, create a global one we can overwrite with Set-Item
4351
function global:prompt { ' ' }

0 commit comments

Comments
 (0)