1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-04 10:34:55 +02:00

Merge pull request #1910 from Ryooooooga/feature/named-author-colors

This commit is contained in:
Jesse Duffield 2022-05-06 08:39:26 +10:00 committed by GitHub
commit 593eb19ca4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 8 deletions

View File

@ -384,7 +384,8 @@ You can customize the color in case you're not happy with the randomly assigned
```yaml
gui:
authorColors:
'John Smith': '#ff0000' # use red for John Smith
'John Smith': 'red' # use red for John Smith
'Alan Smithee': '#00ff00' # use green for Alan Smithee
```
You can use wildcard to set a unified color in case your are lazy to customize the color for every author or you just want a single color for all/other authors:
@ -393,7 +394,7 @@ You can use wildcard to set a unified color in case your are lazy to customize t
gui:
authorColors:
# use red for John Smith
'John Smith': '#ff0000'
'John Smith': 'red'
# use blue for other authors
'*': '#0000ff'
```

View File

@ -6,6 +6,7 @@ import (
"github.com/gookit/color"
"github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/samber/lo"
)
var (
@ -55,10 +56,10 @@ func IsValidHexValue(v string) bool {
}
func SetCustomColors(customColors map[string]string) map[string]style.TextStyle {
colors := make(map[string]style.TextStyle)
for key, colorSequence := range customColors {
style := style.New().SetFg(style.NewRGBColor(color.HEX(colorSequence, false)))
colors[key] = style
}
return colors
return lo.MapValues(customColors, func(c string, key string) style.TextStyle {
if s, ok := style.ColorMap[c]; ok {
return s.Foreground
}
return style.New().SetFg(style.NewRGBColor(color.HEX(c, false)))
})
}