Skip to content

Commit

Permalink
Changed variables, string concat to expansion.
Browse files Browse the repository at this point in the history
Added "File" prefix to (now) FileAddedText, FileModifiedText,
FileRemovedText, and FileConflictedText--before, LocalWorkingStatusSymbol
and ConflictedText had the same content by default ("!"), as did
LocalStagedStatusSymbol and ModifiedText ("~").

Changed prompt output of the above variables to use string expansion
rather than concatenation.

Also re-aligned several indentation blocks from 2-space to 4-space
indents. In my opinion, tabs help avoid these issues, but I'll defer to the
lead coder here.

Several lines had nothing but spaces on them, so I removed the spaces
(keeping the empty double line-break).
  • Loading branch information
Rebecca Turner committed May 5, 2016
1 parent c916d10 commit 6c500d0
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions GitPrompt.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ $global:GitPromptSettings = New-Object PSObject -Property @{
BeforeText = ' ['
BeforeForegroundColor = [ConsoleColor]::Yellow
BeforeBackgroundColor = $Host.UI.RawUI.BackgroundColor

DelimText = ' |'
DelimForegroundColor = [ConsoleColor]::Yellow
DelimBackgroundColor = $Host.UI.RawUI.BackgroundColor
Expand All @@ -16,21 +16,21 @@ $global:GitPromptSettings = New-Object PSObject -Property @{
AfterForegroundColor = [ConsoleColor]::Yellow
AfterBackgroundColor = $Host.UI.RawUI.BackgroundColor

AddedText = '+'
ModifiedText = '~'
RemovedText = '-'
ConflictedText = '!'
FileAddedText = '+'
FileModifiedText = '~'
FileRemovedText = '-'
FileConflictedText = '!'

LocalDefaultStatusSymbol = $null
LocalDefaultStatusForegroundColor = [ConsoleColor]::DarkGreen
LocalDefaultStatusForegroundBrightColor = [ConsoleColor]::Green
LocalDefaultStatusBackgroundColor = $Host.UI.RawUI.BackgroundColor

LocalWorkingStatusSymbol = '!'
LocalWorkingStatusForegroundColor = [ConsoleColor]::DarkRed
LocalWorkingStatusForegroundBrightColor = [ConsoleColor]::Red
LocalWorkingStatusBackgroundColor = $Host.UI.RawUI.BackgroundColor

LocalStagedStatusSymbol = '~'
LocalStagedStatusForegroundColor = [ConsoleColor]::Cyan
LocalStagedStatusBackgroundColor = $Host.UI.RawUI.BackgroundColor
Expand All @@ -42,15 +42,15 @@ $global:GitPromptSettings = New-Object PSObject -Property @{
BranchIdenticalStatusToSymbol = [char]0x2261 # Three horizontal lines
BranchIdenticalStatusToForegroundColor = [ConsoleColor]::Cyan
BranchIdenticalStatusToBackgroundColor = $Host.UI.RawUI.BackgroundColor

BranchAheadStatusSymbol = [char]0x2191 # Up arrow
BranchAheadStatusForegroundColor = [ConsoleColor]::Green
BranchAheadStatusBackgroundColor = $Host.UI.RawUI.BackgroundColor

BranchBehindStatusSymbol = [char]0x2193 # Down arrow
BranchBehindStatusForegroundColor = [ConsoleColor]::Red
BranchBehindStatusBackgroundColor = $Host.UI.RawUI.BackgroundColor

BranchBehindAndAheadStatusSymbol = [char]0x2195 # Up & Down arrow
BranchBehindAndAheadStatusForegroundColor = [ConsoleColor]::Yellow
BranchBehindAndAheadStatusBackgroundColor = $Host.UI.RawUI.BackgroundColor
Expand Down Expand Up @@ -161,7 +161,7 @@ function Write-GitStatus($status) {
}

Write-Prompt (Format-BranchName($status.Branch)) -BackgroundColor $branchStatusBackgroundColor -ForegroundColor $branchStatusForegroundColor

if ($branchStatusSymbol) {
Write-Prompt (" {0}" -f $branchStatusSymbol) -BackgroundColor $branchStatusBackgroundColor -ForegroundColor $branchStatusForegroundColor
}
Expand All @@ -170,17 +170,17 @@ function Write-GitStatus($status) {
Write-Prompt $s.BeforeIndexText -BackgroundColor $s.BeforeIndexBackgroundColor -ForegroundColor $s.BeforeIndexForegroundColor

if($s.ShowStatusWhenZero -or $status.Index.Added) {
Write-Prompt (" " + $s.AddedText + "$($status.Index.Added.Count)") -BackgroundColor $s.IndexBackgroundColor -ForegroundColor $s.IndexForegroundColor
Write-Prompt (" $($s.FileAddedText)$($status.Index.Added.Count)") -BackgroundColor $s.IndexBackgroundColor -ForegroundColor $s.IndexForegroundColor
}
if($s.ShowStatusWhenZero -or $status.Index.Modified) {
Write-Prompt (" " + $s.ModifiedText + "$($status.Index.Modified.Count)") -BackgroundColor $s.IndexBackgroundColor -ForegroundColor $s.IndexForegroundColor
Write-Prompt (" $($s.FileModifiedText)$($status.Index.Modified.Count)") -BackgroundColor $s.IndexBackgroundColor -ForegroundColor $s.IndexForegroundColor
}
if($s.ShowStatusWhenZero -or $status.Index.Deleted) {
Write-Prompt (" " + $s.RemovedText + "$($status.Index.Deleted.Count)") -BackgroundColor $s.IndexBackgroundColor -ForegroundColor $s.IndexForegroundColor
Write-Prompt (" $($s.FileRemovedText)$($status.Index.Deleted.Count)") -BackgroundColor $s.IndexBackgroundColor -ForegroundColor $s.IndexForegroundColor
}

if ($status.Index.Unmerged) {
Write-Prompt (" " + $s.ConflictedText + "$($status.Index.Unmerged.Count)") -BackgroundColor $s.IndexBackgroundColor -ForegroundColor $s.IndexForegroundColor
Write-Prompt (" $($s.FileConflictedText)$($status.Index.Unmerged.Count)") -BackgroundColor $s.IndexBackgroundColor -ForegroundColor $s.IndexForegroundColor
}

if($status.HasWorking) {
Expand All @@ -190,17 +190,17 @@ function Write-GitStatus($status) {

if($s.EnableFileStatus -and $status.HasWorking) {
if($s.ShowStatusWhenZero -or $status.Working.Added) {
Write-Prompt (" " + $s.AddedText + "$($status.Working.Added.Count)") -BackgroundColor $s.WorkingBackgroundColor -ForegroundColor $s.WorkingForegroundColor
Write-Prompt (" $($s.FileAddedText)$($status.Working.Added.Count)") -BackgroundColor $s.WorkingBackgroundColor -ForegroundColor $s.WorkingForegroundColor
}
if($s.ShowStatusWhenZero -or $status.Working.Modified) {
Write-Prompt (" " + $s.ModifiedText + "$($status.Working.Modified.Count)") -BackgroundColor $s.WorkingBackgroundColor -ForegroundColor $s.WorkingForegroundColor
Write-Prompt (" $($s.FileModifiedText)$($status.Working.Modified.Count)") -BackgroundColor $s.WorkingBackgroundColor -ForegroundColor $s.WorkingForegroundColor
}
if($s.ShowStatusWhenZero -or $status.Working.Deleted) {
Write-Prompt (" " + $s.RemovedText + "$($status.Working.Deleted.Count)") -BackgroundColor $s.WorkingBackgroundColor -ForegroundColor $s.WorkingForegroundColor
Write-Prompt (" $($s.FileRemovedText)$($status.Working.Deleted.Count)") -BackgroundColor $s.WorkingBackgroundColor -ForegroundColor $s.WorkingForegroundColor
}

if ($status.Working.Unmerged) {
Write-Prompt (" " + $s.ConflictedText + "$($status.Working.Unmerged.Count)") -BackgroundColor $s.WorkingBackgroundColor -ForegroundColor $s.WorkingForegroundColor
Write-Prompt (" $($s.FileConflictedText)$($status.Working.Unmerged.Count)") -BackgroundColor $s.WorkingBackgroundColor -ForegroundColor $s.WorkingForegroundColor
}
}

Expand All @@ -220,11 +220,11 @@ function Write-GitStatus($status) {
$localStatusBackgroundColor = $s.LocalDefaultStatusBackgroundColor
$localStatusForegroundColor = $s.LocalDefaultStatusForegroundColor
}

if ($localStatusSymbol) {
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
Expand Down Expand Up @@ -255,7 +255,7 @@ $s = $global:GitPromptSettings
if ($Host.UI.RawUI.BackgroundColor -eq [ConsoleColor]::DarkMagenta) {
$s.LocalDefaultStatusForegroundColor = $s.LocalDefaultStatusForegroundBrightColor
$s.LocalWorkingStatusForegroundColor = $s.LocalWorkingStatusForegroundBrightColor

$s.BeforeIndexForegroundColor = $s.BeforeIndexForegroundBrightColor
$s.IndexForegroundColor = $s.IndexForegroundBrightColor

Expand Down

0 comments on commit 6c500d0

Please sign in to comment.