1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-02-09 13:47:11 +02:00

support config unified color for commit authors

This commit is contained in:
Cokile 2021-12-07 18:10:29 +08:00 committed by Jesse Duffield
parent 4f627e5d27
commit 3771f9c98b
2 changed files with 34 additions and 5 deletions

View File

@ -50,8 +50,6 @@ gui:
showRandomTip: true showRandomTip: true
showCommandLog: true showCommandLog: true
commandLogSize: 8 commandLogSize: 8
authorColors: # in case you're not happy with the randomly assigned colour
'John Smith': '#ff0000'
git: git:
paging: paging:
colorArg: always colorArg: always
@ -376,6 +374,28 @@ Alternatively you may have bold fonts disabled in your terminal, in which case e
If you're still having trouble please raise an issue. If you're still having trouble please raise an issue.
## Custom Author Color
Lazygit will assgin a random color for every commit author in the commits pane by default.
You can customize the color in case you're not happy with the randomly assigned one:
```yaml
gui:
authorColors:
'John Smith': '#ff0000 # use red for John Smith
```
You can use wildcard to set a unified color in case your are lazy to customize the color for every author or you are just want a single color for all/other authors:
```yaml
gui:
authorColors:
# use red for John Smith
'John Smith': '#ff0000
# use blue for other authors
'*': '#0000ff'
```
## Example Coloring ## Example Coloring
![border example](../../assets/colored-border-example.png) ![border example](../../assets/colored-border-example.png)

View File

@ -13,9 +13,13 @@ import (
// if these being global variables causes trouble we can wrap them in a struct // if these being global variables causes trouble we can wrap them in a struct
// attached to the gui state. // attached to the gui state.
var authorInitialCache = make(map[string]string) var (
var authorNameCache = make(map[string]string) authorInitialCache = make(map[string]string)
var authorStyleCache = make(map[string]style.TextStyle) authorNameCache = make(map[string]string)
authorStyleCache = make(map[string]style.TextStyle)
)
const authorNameWildcard = "*"
func ShortAuthor(authorName string) string { func ShortAuthor(authorName string) string {
if value, ok := authorInitialCache[authorName]; ok { if value, ok := authorInitialCache[authorName]; ok {
@ -51,6 +55,11 @@ func AuthorStyle(authorName string) style.TextStyle {
return value return value
} }
// use the unified style whatever the autor name is
if value, ok := authorStyleCache[authorNameWildcard]; ok {
return value
}
value := trueColorStyle(authorName) value := trueColorStyle(authorName)
authorStyleCache[authorName] = value authorStyleCache[authorName] = value