diff --git a/docs/Config.md b/docs/Config.md index 5bd531014..b1329f77d 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -50,8 +50,6 @@ gui: showRandomTip: true showCommandLog: true commandLogSize: 8 - authorColors: # in case you're not happy with the randomly assigned colour - 'John Smith': '#ff0000' git: paging: 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. +## 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 ![border example](../../assets/colored-border-example.png) diff --git a/pkg/gui/presentation/authors/authors.go b/pkg/gui/presentation/authors/authors.go index c48683a12..65016142f 100644 --- a/pkg/gui/presentation/authors/authors.go +++ b/pkg/gui/presentation/authors/authors.go @@ -13,9 +13,13 @@ import ( // if these being global variables causes trouble we can wrap them in a struct // attached to the gui state. -var authorInitialCache = make(map[string]string) -var authorNameCache = make(map[string]string) -var authorStyleCache = make(map[string]style.TextStyle) +var ( + authorInitialCache = make(map[string]string) + authorNameCache = make(map[string]string) + authorStyleCache = make(map[string]style.TextStyle) +) + +const authorNameWildcard = "*" func ShortAuthor(authorName string) string { if value, ok := authorInitialCache[authorName]; ok { @@ -51,6 +55,11 @@ func AuthorStyle(authorName string) style.TextStyle { return value } + // use the unified style whatever the autor name is + if value, ok := authorStyleCache[authorNameWildcard]; ok { + return value + } + value := trueColorStyle(authorName) authorStyleCache[authorName] = value