mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-11-10 04:54:03 -08:00
fix(yaml): parse colors correctly
This commit is contained in:
parent
45472c82d2
commit
23b314879b
|
@ -27,14 +27,16 @@ func Default(env runtime.Environment, warning bool) *Config {
|
||||||
Style: Diamond,
|
Style: Diamond,
|
||||||
LeadingDiamond: "\ue0b6",
|
LeadingDiamond: "\ue0b6",
|
||||||
TrailingDiamond: "\ue0b0",
|
TrailingDiamond: "\ue0b0",
|
||||||
Set: color.Set{Foreground: "p:black", Background: "p:yellow"},
|
Foreground: "p:black",
|
||||||
|
Background: "p:yellow",
|
||||||
Template: " {{ if .SSHSession }}\ueba9 {{ end }}{{ .UserName }} ",
|
Template: " {{ if .SSHSession }}\ueba9 {{ end }}{{ .UserName }} ",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Type: PATH,
|
Type: PATH,
|
||||||
Style: Powerline,
|
Style: Powerline,
|
||||||
PowerlineSymbol: "\ue0b0",
|
PowerlineSymbol: "\ue0b0",
|
||||||
Set: color.Set{Foreground: "p:white", Background: "p:orange"},
|
Foreground: "p:white",
|
||||||
|
Background: "p:orange",
|
||||||
Properties: properties.Map{
|
Properties: properties.Map{
|
||||||
properties.Style: "folder",
|
properties.Style: "folder",
|
||||||
},
|
},
|
||||||
|
@ -44,7 +46,8 @@ func Default(env runtime.Environment, warning bool) *Config {
|
||||||
Type: GIT,
|
Type: GIT,
|
||||||
Style: Powerline,
|
Style: Powerline,
|
||||||
PowerlineSymbol: "\ue0b0",
|
PowerlineSymbol: "\ue0b0",
|
||||||
Set: color.Set{Foreground: "p:black", Background: "p:green"},
|
Foreground: "p:black",
|
||||||
|
Background: "p:green",
|
||||||
BackgroundTemplates: []string{
|
BackgroundTemplates: []string{
|
||||||
"{{ if or (.Working.Changed) (.Staging.Changed) }}p:yellow{{ end }}",
|
"{{ if or (.Working.Changed) (.Staging.Changed) }}p:yellow{{ end }}",
|
||||||
"{{ if and (gt .Ahead 0) (gt .Behind 0) }}p:red{{ 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,
|
Type: ROOT,
|
||||||
Style: Powerline,
|
Style: Powerline,
|
||||||
PowerlineSymbol: "\ue0b0",
|
PowerlineSymbol: "\ue0b0",
|
||||||
Set: color.Set{Foreground: "p:white", Background: "p:yellow"},
|
Foreground: "p:white",
|
||||||
|
Background: "p:yellow",
|
||||||
Template: " \uf0e7 ",
|
Template: " \uf0e7 ",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -75,7 +79,8 @@ func Default(env runtime.Environment, warning bool) *Config {
|
||||||
Style: Diamond,
|
Style: Diamond,
|
||||||
LeadingDiamond: "<transparent,background>\ue0b0</>",
|
LeadingDiamond: "<transparent,background>\ue0b0</>",
|
||||||
TrailingDiamond: "\ue0b4",
|
TrailingDiamond: "\ue0b4",
|
||||||
Set: color.Set{Foreground: "p:white", Background: "p:blue"},
|
Foreground: "p:white",
|
||||||
|
Background: "p:blue",
|
||||||
BackgroundTemplates: []string{
|
BackgroundTemplates: []string{
|
||||||
exitBackgroundTemplate,
|
exitBackgroundTemplate,
|
||||||
},
|
},
|
||||||
|
@ -90,10 +95,11 @@ func Default(env runtime.Environment, warning bool) *Config {
|
||||||
Type: RPrompt,
|
Type: RPrompt,
|
||||||
Segments: []*Segment{
|
Segments: []*Segment{
|
||||||
{
|
{
|
||||||
Type: NODE,
|
Type: NODE,
|
||||||
Style: Plain,
|
Style: Plain,
|
||||||
Set: color.Set{Foreground: "p:green", Background: "transparent"},
|
Foreground: "p:green",
|
||||||
Template: "\ue718 ",
|
Background: "transparent",
|
||||||
|
Template: "\ue718 ",
|
||||||
Properties: properties.Map{
|
Properties: properties.Map{
|
||||||
segments.HomeEnabled: false,
|
segments.HomeEnabled: false,
|
||||||
segments.FetchPackageManager: false,
|
segments.FetchPackageManager: false,
|
||||||
|
@ -101,19 +107,21 @@ func Default(env runtime.Environment, warning bool) *Config {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Type: GOLANG,
|
Type: GOLANG,
|
||||||
Style: Plain,
|
Style: Plain,
|
||||||
Set: color.Set{Foreground: "p:blue", Background: "transparent"},
|
Foreground: "p:blue",
|
||||||
Template: "\ue626 ",
|
Background: "transparent",
|
||||||
|
Template: "\ue626 ",
|
||||||
Properties: properties.Map{
|
Properties: properties.Map{
|
||||||
properties.FetchVersion: false,
|
properties.FetchVersion: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Type: PYTHON,
|
Type: PYTHON,
|
||||||
Style: Plain,
|
Style: Plain,
|
||||||
Set: color.Set{Foreground: "p:yellow", Background: "transparent"},
|
Foreground: "p:yellow",
|
||||||
Template: "\ue235 ",
|
Background: "transparent",
|
||||||
|
Template: "\ue235 ",
|
||||||
Properties: properties.Map{
|
Properties: properties.Map{
|
||||||
properties.FetchVersion: false,
|
properties.FetchVersion: false,
|
||||||
segments.DisplayMode: "files",
|
segments.DisplayMode: "files",
|
||||||
|
@ -121,16 +129,18 @@ func Default(env runtime.Environment, warning bool) *Config {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Type: SHELL,
|
Type: SHELL,
|
||||||
Style: Plain,
|
Style: Plain,
|
||||||
Set: color.Set{Foreground: "p:white", Background: "transparent"},
|
Foreground: "p:white",
|
||||||
Template: "in <p:blue><b>{{ .Name }}</b></> ",
|
Background: "transparent",
|
||||||
|
Template: "in <p:blue><b>{{ .Name }}</b></> ",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Type: TIME,
|
Type: TIME,
|
||||||
Style: Plain,
|
Style: Plain,
|
||||||
Set: color.Set{Foreground: "p:white", Background: "transparent"},
|
Foreground: "p:white",
|
||||||
Template: "at <p:blue><b>{{ .CurrentDate | date \"15:04:05\" }}</b></>",
|
Background: "transparent",
|
||||||
|
Template: "at <p:blue><b>{{ .CurrentDate | date \"15:04:05\" }}</b></>",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -146,12 +156,14 @@ func Default(env runtime.Environment, warning bool) *Config {
|
||||||
"yellow": "#F3AE35",
|
"yellow": "#F3AE35",
|
||||||
},
|
},
|
||||||
SecondaryPrompt: &Segment{
|
SecondaryPrompt: &Segment{
|
||||||
Set: color.Set{Foreground: "p:black", Background: "transparent"},
|
Foreground: "p:black",
|
||||||
Template: "<p:yellow,transparent>\ue0b6</><,p:yellow> > </><p:yellow,transparent>\ue0b0</> ",
|
Background: "transparent",
|
||||||
|
Template: "<p:yellow,transparent>\ue0b6</><,p:yellow> > </><p:yellow,transparent>\ue0b0</> ",
|
||||||
},
|
},
|
||||||
TransientPrompt: &Segment{
|
TransientPrompt: &Segment{
|
||||||
Set: color.Set{Foreground: "p:black", Background: "transparent"},
|
Foreground: "p:black",
|
||||||
Template: "<p:yellow,transparent>\ue0b6</><,p:yellow> {{ .Folder }} </><p:yellow,transparent>\ue0b0</> ",
|
Background: "transparent",
|
||||||
|
Template: "<p:yellow,transparent>\ue0b6</><,p:yellow> {{ .Folder }} </><p:yellow,transparent>\ue0b0</> ",
|
||||||
},
|
},
|
||||||
Tooltips: []*Segment{
|
Tooltips: []*Segment{
|
||||||
{
|
{
|
||||||
|
@ -159,7 +171,8 @@ func Default(env runtime.Environment, warning bool) *Config {
|
||||||
Style: Diamond,
|
Style: Diamond,
|
||||||
LeadingDiamond: "\ue0b0",
|
LeadingDiamond: "\ue0b0",
|
||||||
TrailingDiamond: "\ue0b4",
|
TrailingDiamond: "\ue0b4",
|
||||||
Set: color.Set{Foreground: "p:white", Background: "p:orange"},
|
Foreground: "p:white",
|
||||||
|
Background: "p:orange",
|
||||||
Template: " \ue7ad {{ .Profile }}{{ if .Region }}@{{ .Region }}{{ end }} ",
|
Template: " \ue7ad {{ .Profile }}{{ if .Region }}@{{ .Region }}{{ end }} ",
|
||||||
Properties: properties.Map{
|
Properties: properties.Map{
|
||||||
properties.DisplayDefault: true,
|
properties.DisplayDefault: true,
|
||||||
|
@ -171,7 +184,8 @@ func Default(env runtime.Environment, warning bool) *Config {
|
||||||
Style: Diamond,
|
Style: Diamond,
|
||||||
LeadingDiamond: "\ue0b0",
|
LeadingDiamond: "\ue0b0",
|
||||||
TrailingDiamond: "\ue0b4",
|
TrailingDiamond: "\ue0b4",
|
||||||
Set: color.Set{Foreground: "p:white", Background: "p:blue"},
|
Foreground: "p:white",
|
||||||
|
Background: "p:blue",
|
||||||
Template: " \uebd8 {{ .Name }} ",
|
Template: " \uebd8 {{ .Name }} ",
|
||||||
Properties: properties.Map{
|
Properties: properties.Map{
|
||||||
properties.DisplayDefault: true,
|
properties.DisplayDefault: true,
|
||||||
|
|
|
@ -53,7 +53,9 @@ type Segment struct {
|
||||||
MaxWidth int `json:"max_width,omitempty" toml:"max_width,omitempty"`
|
MaxWidth int `json:"max_width,omitempty" toml:"max_width,omitempty"`
|
||||||
MinWidth int `json:"min_width,omitempty" toml:"min_width,omitempty"`
|
MinWidth int `json:"min_width,omitempty" toml:"min_width,omitempty"`
|
||||||
Filler string `json:"filler,omitempty" toml:"filler,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:"-"`
|
Enabled bool `json:"-" toml:"-"`
|
||||||
|
|
||||||
|
@ -214,19 +216,19 @@ func (segment *Segment) cwdExcluded() bool {
|
||||||
func (segment *Segment) ResolveForeground() color.Ansi {
|
func (segment *Segment) ResolveForeground() color.Ansi {
|
||||||
if len(segment.ForegroundTemplates) != 0 {
|
if len(segment.ForegroundTemplates) != 0 {
|
||||||
match := segment.ForegroundTemplates.FirstMatch(segment.writer, segment.env, segment.Foreground.String())
|
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 {
|
func (segment *Segment) ResolveBackground() color.Ansi {
|
||||||
if len(segment.BackgroundTemplates) != 0 {
|
if len(segment.BackgroundTemplates) != 0 {
|
||||||
match := segment.BackgroundTemplates.FirstMatch(segment.writer, segment.env, segment.Background.String())
|
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 {
|
func (segment *Segment) ResolveStyle() SegmentStyle {
|
||||||
|
|
|
@ -306,7 +306,8 @@ func (e *Engine) renderBlockSegments(block *config.Block) (string, int) {
|
||||||
for i, segment := range block.Segments {
|
for i, segment := range block.Segments {
|
||||||
if colors, newCycle := cycle.Loop(); colors != nil {
|
if colors, newCycle := cycle.Loop(); colors != nil {
|
||||||
cycle = &newCycle
|
cycle = &newCycle
|
||||||
segment.Set = *colors
|
segment.Foreground = colors.Foreground
|
||||||
|
segment.Background = colors.Background
|
||||||
}
|
}
|
||||||
|
|
||||||
if i == 0 && len(block.LeadingDiamond) > 0 {
|
if i == 0 && len(block.LeadingDiamond) > 0 {
|
||||||
|
|
Loading…
Reference in a new issue