oh-my-posh/src/segments/posh_git.go
2022-02-03 10:44:18 +01:00

34 lines
553 B
Go

package segments
import (
"oh-my-posh/environment"
"oh-my-posh/properties"
"strings"
)
type PoshGit struct {
props properties.Properties
env environment.Environment
Status string
}
const (
poshGitEnv = "POSH_GIT_STATUS"
)
func (p *PoshGit) Template() string {
return " {{ .Status }} "
}
func (p *PoshGit) Enabled() bool {
status := p.env.Getenv(poshGitEnv)
p.Status = strings.TrimSpace(status)
return p.Status != ""
}
func (p *PoshGit) Init(props properties.Properties, env environment.Environment) {
p.props = props
p.env = env
}