aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Daniel Smith <rdnlsmith@gmail.com> 2020-03-01 21:22:37 -0500
committerGravatar Daniel Smith <rdnlsmith@gmail.com> 2020-03-01 21:22:37 -0500
commitfe7e28576ac7044a89b4db3d4357bd219e43ccea (patch)
tree677caa7d724b861373e86e01e2cf6303aeecf757
parent5385d12e3bedd22a3de8ae5dfdc557b809c33a49 (diff)
Read diff-highlight colors from git config
-rwxr-xr-xpwsh-diff25
1 files changed, 21 insertions, 4 deletions
diff --git a/pwsh-diff b/pwsh-diff
index 77633ed..7ad2478 100755
--- a/pwsh-diff
+++ b/pwsh-diff
@@ -134,6 +134,23 @@ function Get-GitConfigBoolean {
}
}
+function Get-GitConfigColor {
+ param (
+ [string]$key,
+ [string]$default
+ )
+
+ $color = $(git config --get --type=color "$key")
+
+ # `git config` has a `--default` option, but it doesn't seem to like the
+ # output from `Get-Color`.
+ if (!$color) {
+ $color = Get-Color $default
+ }
+
+ return $color
+}
+
function Get-VisibleString {
param (
[string]$str
@@ -343,13 +360,13 @@ function Write-Hunk {
$addedTheme = [HighlightTheme]@{
- NormalColor = Get-Color "39"
- HighlightColor = Get-Color "39 on_4"
+ NormalColor = Get-GitConfigColor "color.diff-highlight.newNormal" "green bold"
+ HighlightColor = Get-GitConfigColor "color.diff-highlight.newHighlight" "green bold on_22"
}
$removedTheme = [HighlightTheme]@{
- NormalColor = Get-Color "13"
- HighlightColor = Get-Color "13 on_5"
+ NormalColor = Get-GitConfigColor "color.diff-highlight.oldNormal" "red bold"
+ HighlightColor = Get-GitConfigColor "color.diff-highlight.oldHighlight" "red bold on_52"
}
$inHunk = $false