Permalink
Browse files

Add Write-VcsStatus to easily support multiple VCS prompts

  • Loading branch information...
1 parent 00d7c91 commit bcdef7a2dca9677c3550251f7a89dc8dff97d6b2 @dahlbyk committed Jan 26, 2012
Showing with 11 additions and 5 deletions.
  1. +9 −0 GitPrompt.ps1
  2. +0 −1 posh-git.psm1
  3. +2 −4 profile.example.ps1
View
@@ -109,3 +109,12 @@ function Write-GitStatus($status) {
Write-Host $s.AfterText -NoNewline -BackgroundColor $s.AfterBackgroundColor -ForegroundColor $s.AfterForegroundColor
}
}
+
+if (!$Global:VcsPromptStatuses) { $Global:VcsPromptStatuses = @() }
+function Global:Write-VcsStatus { $Global:VcsPromptStatuses | foreach { & $_ } }
+
+# Add scriptblock that will execute for Write-VcsStatus
+$Global:VcsPromptStatuses += {
+ $Global:GitStatus = Get-GitStatus
+ Write-GitStatus $GitStatus
+}
View
@@ -9,7 +9,6 @@ Push-Location $psScriptRoot
Pop-Location
Export-ModuleMember -Function @(
- 'Write-GitStatus',
'Get-GitStatus',
'Enable-GitColors',
'Get-GitDirectory',
View
@@ -16,10 +16,8 @@ function prompt {
$Host.UI.RawUI.ForegroundColor = $GitPromptSettings.DefaultForegroundColor
Write-Host($pwd) -nonewline
-
- # Git Prompt
- $Global:GitStatus = Get-GitStatus
- Write-GitStatus $GitStatus
+
+ Write-VcsStatus
$LASTEXITCODE = $realLASTEXITCODE
return "> "

0 comments on commit bcdef7a

Please sign in to comment.