fix(segment): only case non-alias

relates to #3103
This commit is contained in:
Jan De Dobbeleer 2022-11-26 15:44:08 +01:00 committed by Jan De Dobbeleer
parent 35edf3a93d
commit 389262edd0
2 changed files with 4 additions and 4 deletions

View file

@ -12,6 +12,9 @@ import (
"oh-my-posh/segments"
"oh-my-posh/shell"
"oh-my-posh/template"
c "golang.org/x/text/cases"
"golang.org/x/text/language"
)
// Segment represent a single segment and it's configuration
@ -397,7 +400,7 @@ func (segment *Segment) SetEnabled(env platform.Environment) {
segment.Enabled = true
name := segment.Alias
if len(name) == 0 {
name = string(segment.Type)
name = c.Title(language.English).String(string(segment.Type))
}
env.TemplateCache().AddSegmentData(name, segment.writer)
}

View file

@ -24,8 +24,6 @@ import (
"time"
process "github.com/shirou/gopsutil/v3/process"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)
const (
@ -158,7 +156,6 @@ func (t *TemplateCache) AddSegmentData(key string, value interface{}) {
if t.Segments == nil {
t.Segments = make(map[string]interface{})
}
key = cases.Title(language.English).String(key)
t.Segments[key] = value
}