diff options
author | Cokile <kelvintgx@gmail.com> | 2021-12-07 18:10:29 +0800 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-12-25 11:54:27 +1100 |
commit | 3771f9c98b8083f65599dc8c1a4262bf46d8ff27 (patch) | |
tree | d54bbf190749992378109b845b2a8cd70b8cf1a4 | |
parent | 4f627e5d27ed0b1f5767bd5b629616b30a9fa011 (diff) |
support config unified color for commit authors
-rw-r--r-- | docs/Config.md | 24 | ||||
-rw-r--r-- | pkg/gui/presentation/authors/authors.go | 15 |
2 files changed, 34 insertions, 5 deletions
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 |