diff --git a/pkg/gui/custom_commands.go b/pkg/gui/custom_commands.go index d43f028cb..8f98d6597 100644 --- a/pkg/gui/custom_commands.go +++ b/pkg/gui/custom_commands.go @@ -136,10 +136,7 @@ func (gui *Gui) GenerateMenuCandidates(commandOutput, filter, valueFormat, label return nil, gui.surfaceError(errors.New("unable to parse value format, error: " + err.Error())) } - colorFuncMap := template.FuncMap{} - for k, v := range style.ColorMap { - colorFuncMap[k] = v.Foreground.Sprint - } + colorFuncMap := style.TemplateFuncMapAddColors(template.FuncMap{}) descTemp, err := template.New("format").Funcs(colorFuncMap).Parse(labelFormat) if err != nil { diff --git a/pkg/gui/style/basic_styles.go b/pkg/gui/style/basic_styles.go index 373172a8b..92b034f06 100644 --- a/pkg/gui/style/basic_styles.go +++ b/pkg/gui/style/basic_styles.go @@ -2,6 +2,7 @@ package style import ( "github.com/gookit/color" + "text/template" ) var ( @@ -51,3 +52,12 @@ func FromBasicFg(fg color.Color) TextStyle { func FromBasicBg(bg color.Color) TextStyle { return New().SetBg(NewBasicColor(bg)) } + +func TemplateFuncMapAddColors(m template.FuncMap) template.FuncMap { + for k, v := range ColorMap { + m[k] = v.Foreground.Sprint + } + m["underline"] = color.OpUnderscore.Sprint + m["bold"] = color.OpBold.Sprint + return m +} diff --git a/pkg/theme/style.go b/pkg/theme/style.go index 8f607256d..69c404e3b 100644 --- a/pkg/theme/style.go +++ b/pkg/theme/style.go @@ -6,8 +6,6 @@ import ( "github.com/jesseduffield/lazygit/pkg/utils" ) -var colorMap = style.ColorMap - func GetTextStyle(keys []string, background bool) style.TextStyle { s := style.New() @@ -20,7 +18,7 @@ func GetTextStyle(keys []string, background bool) style.TextStyle { case "underline": s = s.SetUnderline() default: - value, present := colorMap[key] + value, present := style.ColorMap[key] if present { var c style.TextStyle if background {