diff --git a/GitPrompt.ps1 b/GitPrompt.ps1 index 53d572c31..865136efa 100644 --- a/GitPrompt.ps1 +++ b/GitPrompt.ps1 @@ -63,6 +63,16 @@ $global:GitPromptSettings = New-Object PSObject -Property @{ WorkingForegroundBrightColor = [ConsoleColor]::Red WorkingBackgroundColor = $Host.UI.RawUI.BackgroundColor + EnableStashStatus = $false + BeforeStashText = ' (' + BeforeStashBackgroundColor = $Host.UI.RawUI.BackgroundColor + BeforeStashForegroundColor = [ConsoleColor]::Red + AfterStashText = ')' + AfterStashBackgroundColor = $Host.UI.RawUI.BackgroundColor + AfterStashForegroundColor = [ConsoleColor]::Red + StashBackgroundColor = $Host.UI.RawUI.BackgroundColor + StashForegroundColor = [ConsoleColor]::Red + ShowStatusWhenZero = $true AutoRefreshIndex = $true @@ -210,6 +220,12 @@ function Write-GitStatus($status) { Write-Prompt (" {0}" -f $localStatusSymbol) -BackgroundColor $localStatusBackgroundColor -ForegroundColor $localStatusForegroundColor } + if ($s.EnableStashStatus -and ($status.StashCount -gt 0)) { + Write-Prompt $s.BeforeStashText -BackgroundColor $s.BeforeStashBackgroundColor -ForegroundColor $s.BeforeStashForegroundColor + Write-Prompt $status.StashCount -BackgroundColor $s.StashBackgroundColor -ForegroundColor $s.StashForegroundColor + Write-Prompt $s.AfterStashText -BackgroundColor $s.AfterStashBackgroundColor -ForegroundColor $s.AfterStashForegroundColor + } + Write-Prompt $s.AfterText -BackgroundColor $s.AfterBackgroundColor -ForegroundColor $s.AfterForegroundColor if ($WindowTitleSupported -and $s.EnableWindowTitle) { diff --git a/GitUtils.ps1 b/GitUtils.ps1 index 0974c4cb7..98cc8ed73 100644 --- a/GitUtils.ps1 +++ b/GitUtils.ps1 @@ -115,10 +115,12 @@ function Get-GitStatus($gitDir = (Get-GitDirectory)) { $filesModified = @() $filesDeleted = @() $filesUnmerged = @() + $stashCount = 0 if($settings.EnableFileStatus -and !$(InDisabledRepository)) { dbg 'Getting status' $sw $status = git -c color.status=false status --short --branch 2>$null + $stashCount = $null | git stash list 2>$null | measure-object | select -expand Count } else { $status = @() } @@ -186,6 +188,7 @@ function Get-GitStatus($gitDir = (Get-GitDirectory)) { HasWorking = [bool]$working Working = $working HasUntracked = [bool]$filesAdded + StashCount = $stashCount } dbg 'Finished' $sw