Skip to content

Commit

Permalink
Redid the Stash-Status from PR #181 from fritzh
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusAmshove committed Sep 1, 2015
1 parent fae88a8 commit c2913a3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
16 changes: 16 additions & 0 deletions GitPrompt.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions GitUtils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 = @()
}
Expand Down Expand Up @@ -186,6 +188,7 @@ function Get-GitStatus($gitDir = (Get-GitDirectory)) {
HasWorking = [bool]$working
Working = $working
HasUntracked = [bool]$filesAdded
stashCount = $stashCount
}

dbg 'Finished' $sw
Expand Down

0 comments on commit c2913a3

Please sign in to comment.