diff --git a/src/config/default.go b/src/config/default.go index 3e151a1bab4c..457e39b9bc51 100644 --- a/src/config/default.go +++ b/src/config/default.go @@ -27,14 +27,16 @@ func Default(env runtime.Environment, warning bool) *Config { Style: Diamond, LeadingDiamond: "\ue0b6", TrailingDiamond: "\ue0b0", - Set: color.Set{Foreground: "p:black", Background: "p:yellow"}, + Foreground: "p:black", + Background: "p:yellow", Template: " {{ if .SSHSession }}\ueba9 {{ end }}{{ .UserName }} ", }, { Type: PATH, Style: Powerline, PowerlineSymbol: "\ue0b0", - Set: color.Set{Foreground: "p:white", Background: "p:orange"}, + Foreground: "p:white", + Background: "p:orange", Properties: properties.Map{ properties.Style: "folder", }, @@ -44,7 +46,8 @@ func Default(env runtime.Environment, warning bool) *Config { Type: GIT, Style: Powerline, PowerlineSymbol: "\ue0b0", - Set: color.Set{Foreground: "p:black", Background: "p:green"}, + Foreground: "p:black", + Background: "p:green", BackgroundTemplates: []string{ "{{ if or (.Working.Changed) (.Staging.Changed) }}p:yellow{{ end }}", "{{ if and (gt .Ahead 0) (gt .Behind 0) }}p:red{{ end }}", @@ -67,7 +70,8 @@ func Default(env runtime.Environment, warning bool) *Config { Type: ROOT, Style: Powerline, PowerlineSymbol: "\ue0b0", - Set: color.Set{Foreground: "p:white", Background: "p:yellow"}, + Foreground: "p:white", + Background: "p:yellow", Template: " \uf0e7 ", }, { @@ -75,7 +79,8 @@ func Default(env runtime.Environment, warning bool) *Config { Style: Diamond, LeadingDiamond: "\ue0b0", TrailingDiamond: "\ue0b4", - Set: color.Set{Foreground: "p:white", Background: "p:blue"}, + Foreground: "p:white", + Background: "p:blue", BackgroundTemplates: []string{ exitBackgroundTemplate, }, @@ -90,10 +95,11 @@ func Default(env runtime.Environment, warning bool) *Config { Type: RPrompt, Segments: []*Segment{ { - Type: NODE, - Style: Plain, - Set: color.Set{Foreground: "p:green", Background: "transparent"}, - Template: "\ue718 ", + Type: NODE, + Style: Plain, + Foreground: "p:green", + Background: "transparent", + Template: "\ue718 ", Properties: properties.Map{ segments.HomeEnabled: false, segments.FetchPackageManager: false, @@ -101,19 +107,21 @@ func Default(env runtime.Environment, warning bool) *Config { }, }, { - Type: GOLANG, - Style: Plain, - Set: color.Set{Foreground: "p:blue", Background: "transparent"}, - Template: "\ue626 ", + Type: GOLANG, + Style: Plain, + Foreground: "p:blue", + Background: "transparent", + Template: "\ue626 ", Properties: properties.Map{ properties.FetchVersion: false, }, }, { - Type: PYTHON, - Style: Plain, - Set: color.Set{Foreground: "p:yellow", Background: "transparent"}, - Template: "\ue235 ", + Type: PYTHON, + Style: Plain, + Foreground: "p:yellow", + Background: "transparent", + Template: "\ue235 ", Properties: properties.Map{ properties.FetchVersion: false, segments.DisplayMode: "files", @@ -121,16 +129,18 @@ func Default(env runtime.Environment, warning bool) *Config { }, }, { - Type: SHELL, - Style: Plain, - Set: color.Set{Foreground: "p:white", Background: "transparent"}, - Template: "in {{ .Name }} ", + Type: SHELL, + Style: Plain, + Foreground: "p:white", + Background: "transparent", + Template: "in {{ .Name }} ", }, { - Type: TIME, - Style: Plain, - Set: color.Set{Foreground: "p:white", Background: "transparent"}, - Template: "at {{ .CurrentDate | date \"15:04:05\" }}", + Type: TIME, + Style: Plain, + Foreground: "p:white", + Background: "transparent", + Template: "at {{ .CurrentDate | date \"15:04:05\" }}", }, }, }, @@ -146,12 +156,14 @@ func Default(env runtime.Environment, warning bool) *Config { "yellow": "#F3AE35", }, SecondaryPrompt: &Segment{ - Set: color.Set{Foreground: "p:black", Background: "transparent"}, - Template: "\ue0b6<,p:yellow> > \ue0b0 ", + Foreground: "p:black", + Background: "transparent", + Template: "\ue0b6<,p:yellow> > \ue0b0 ", }, TransientPrompt: &Segment{ - Set: color.Set{Foreground: "p:black", Background: "transparent"}, - Template: "\ue0b6<,p:yellow> {{ .Folder }} \ue0b0 ", + Foreground: "p:black", + Background: "transparent", + Template: "\ue0b6<,p:yellow> {{ .Folder }} \ue0b0 ", }, Tooltips: []*Segment{ { @@ -159,7 +171,8 @@ func Default(env runtime.Environment, warning bool) *Config { Style: Diamond, LeadingDiamond: "\ue0b0", TrailingDiamond: "\ue0b4", - Set: color.Set{Foreground: "p:white", Background: "p:orange"}, + Foreground: "p:white", + Background: "p:orange", Template: " \ue7ad {{ .Profile }}{{ if .Region }}@{{ .Region }}{{ end }} ", Properties: properties.Map{ properties.DisplayDefault: true, @@ -171,7 +184,8 @@ func Default(env runtime.Environment, warning bool) *Config { Style: Diamond, LeadingDiamond: "\ue0b0", TrailingDiamond: "\ue0b4", - Set: color.Set{Foreground: "p:white", Background: "p:blue"}, + Foreground: "p:white", + Background: "p:blue", Template: " \uebd8 {{ .Name }} ", Properties: properties.Map{ properties.DisplayDefault: true, diff --git a/src/config/segment.go b/src/config/segment.go index b3fd0052b177..2b9d88ea4e37 100644 --- a/src/config/segment.go +++ b/src/config/segment.go @@ -53,7 +53,9 @@ type Segment struct { MaxWidth int `json:"max_width,omitempty" toml:"max_width,omitempty"` MinWidth int `json:"min_width,omitempty" toml:"min_width,omitempty"` Filler string `json:"filler,omitempty" toml:"filler,omitempty"` - color.Set + Background color.Ansi `json:"background" toml:"background"` + Foreground color.Ansi `json:"foreground" toml:"foreground"` + // color.Set Enabled bool `json:"-" toml:"-"` @@ -214,19 +216,19 @@ func (segment *Segment) cwdExcluded() bool { func (segment *Segment) ResolveForeground() color.Ansi { if len(segment.ForegroundTemplates) != 0 { match := segment.ForegroundTemplates.FirstMatch(segment.writer, segment.env, segment.Foreground.String()) - segment.Set.Foreground = color.Ansi(match) + segment.Foreground = color.Ansi(match) } - return segment.Set.Foreground + return segment.Foreground } func (segment *Segment) ResolveBackground() color.Ansi { if len(segment.BackgroundTemplates) != 0 { match := segment.BackgroundTemplates.FirstMatch(segment.writer, segment.env, segment.Background.String()) - segment.Set.Background = color.Ansi(match) + segment.Background = color.Ansi(match) } - return segment.Set.Background + return segment.Background } func (segment *Segment) ResolveStyle() SegmentStyle { diff --git a/src/prompt/engine.go b/src/prompt/engine.go index 1a0845a4cd4f..3664a63cad32 100644 --- a/src/prompt/engine.go +++ b/src/prompt/engine.go @@ -306,7 +306,8 @@ func (e *Engine) renderBlockSegments(block *config.Block) (string, int) { for i, segment := range block.Segments { if colors, newCycle := cycle.Loop(); colors != nil { cycle = &newCycle - segment.Set = *colors + segment.Foreground = colors.Foreground + segment.Background = colors.Background } if i == 0 && len(block.LeadingDiamond) > 0 {