summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/Config.md10
-rw-r--r--pkg/config/user_config.go1
-rw-r--r--pkg/gui/gui.go2
-rw-r--r--pkg/gui/presentation/branches.go14
4 files changed, 27 insertions, 0 deletions
diff --git a/docs/Config.md b/docs/Config.md
index b83346610..ed6f6dfde 100644
--- a/docs/Config.md
+++ b/docs/Config.md
@@ -400,6 +400,16 @@ gui:
'*': '#0000ff'
```
+## Custom Branch Color
+
+You can customize the color of branches based on the branch prefix:
+
+```yaml
+gui:
+ branchColors:
+ 'docs': '#11aaff' # use a light blue for branches beginning with 'docs/'
+```
+
## Example Coloring
![border example](../../assets/colored-border-example.png)
diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go
index a9977bdf6..9d7781358 100644
--- a/pkg/config/user_config.go
+++ b/pkg/config/user_config.go
@@ -25,6 +25,7 @@ type RefresherConfig struct {
type GuiConfig struct {
AuthorColors map[string]string `yaml:"authorColors"`
+ BranchColors map[string]string `yaml:"branchColors"`
ScrollHeight int `yaml:"scrollHeight"`
ScrollPastBottom bool `yaml:"scrollPastBottom"`
MouseEvents bool `yaml:"mouseEvents"`
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index 3549e186f..c0cb9692c 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -25,6 +25,7 @@ import (
"github.com/jesseduffield/lazygit/pkg/gui/modes/diffing"
"github.com/jesseduffield/lazygit/pkg/gui/modes/filtering"
"github.com/jesseduffield/lazygit/pkg/gui/presentation/authors"
+ "github.com/jesseduffield/lazygit/pkg/gui/presentation"
"github.com/jesseduffield/lazygit/pkg/gui/presentation/graph"
"github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/gui/types"
@@ -492,6 +493,7 @@ func NewGui(
gui.PopupHandler = &RealPopupHandler{gui: gui}
authors.SetCustomAuthors(gui.UserConfig.Gui.AuthorColors)
+ presentation.SetCustomBranchColors(gui.UserConfig.Gui.BranchColors)
return gui, nil
}
diff --git a/pkg/gui/presentation/branches.go b/pkg/gui/presentation/branches.go
index c8a613516..50a4ef094 100644
--- a/pkg/gui/presentation/branches.go
+++ b/pkg/gui/presentation/branches.go
@@ -4,11 +4,14 @@ import (
"fmt"
"strings"
+ "github.com/gookit/color"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/theme"
)
+var branchPrefixColors = make(map[string]style.TextStyle)
+
func GetBranchListDisplayStrings(branches []*models.Branch, fullDescription bool, diffName string) [][]string {
lines := make([][]string, len(branches))
@@ -58,6 +61,10 @@ func getBranchDisplayStrings(b *models.Branch, fullDescription bool, diffed bool
func GetBranchTextStyle(name string) style.TextStyle {
branchType := strings.Split(name, "/")[0]
+ if value, ok := branchPrefixColors[branchType]; ok {
+ return value
+ }
+
switch branchType {
case "feature":
return style.FgGreen
@@ -84,3 +91,10 @@ func ColoredBranchStatus(branch *models.Branch) string {
func BranchStatus(branch *models.Branch) string {
return fmt.Sprintf("ā†‘%sā†“%s", branch.Pushables, branch.Pullables)
}
+
+func SetCustomBranchColors(customBranchColors map[string]string) {
+ for branchPrefix, colorSequence := range customBranchColors {
+ style := style.New().SetFg(style.NewRGBColor(color.HEX(colorSequence, false)))
+ branchPrefixColors[branchPrefix] = style
+ }
+}