Skip to content

Commit 20fa42f

Browse files
committed
Use DefaultForegroundColor for prompt text
The setting exists for legacy reasons: 02956e1. It was removed in #202 and restored in #209 to avoid a breaking change. Since we still have it, I suppose we might as well support using it to control the prompt text color.
1 parent 303fbd0 commit 20fa42f

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/GitPrompt.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ if (Get-Module NuGet) {
128128
}
129129

130130
function Write-Prompt($Object, $ForegroundColor = $null, $BackgroundColor = $null) {
131+
$s = $global:GitPromptSettings
132+
if ($s -and !$ForegroundColor) {
133+
$ForegroundColor = $s.DefaultForegroundColor
134+
}
135+
131136
if ($BackgroundColor -is [string]) {
132137
$BackgroundColor = [ConsoleColor]$BackgroundColor
133138
}

src/posh-git.psm1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ if ($ForcePoshGitPrompt -or !$currentPromptDef -or ($currentPromptDef -eq $defau
8585
$defaultPromptPrefix = [string]$GitPromptSettings.DefaultPromptPrefix
8686
if ($defaultPromptPrefix) {
8787
$expandedDefaultPromptPrefix = $ExecutionContext.SessionState.InvokeCommand.ExpandString($defaultPromptPrefix)
88-
Write-Host $expandedDefaultPromptPrefix -NoNewline
88+
Write-Prompt $expandedDefaultPromptPrefix
8989
}
9090
9191
# Write the abbreviated current path
92-
Write-Host $currentPath -NoNewline
92+
Write-Prompt $currentPath -NoNewline
9393
9494
# Write the Git status summary information
9595
Write-VcsStatus
@@ -110,7 +110,7 @@ if ($ForcePoshGitPrompt -or !$currentPromptDef -or ($currentPromptDef -eq $defau
110110
if ($GitPromptSettings.DefaultPromptEnableTiming) {
111111
$sw.Stop()
112112
$elapsed = $sw.ElapsedMilliseconds
113-
Write-Host " ${elapsed}ms" -NoNewline
113+
Write-Prompt " ${elapsed}ms" -NoNewline
114114
}
115115
116116
$global:LASTEXITCODE = $origLastExitCode

0 commit comments

Comments
 (0)