mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-01-07 09:17:26 -08:00
9214b88475
resolves #2108
43 lines
826 B
Go
43 lines
826 B
Go
package segments
|
|
|
|
import (
|
|
"oh-my-posh/environment"
|
|
"oh-my-posh/properties"
|
|
"strings"
|
|
)
|
|
|
|
type Shell struct {
|
|
props properties.Properties
|
|
env environment.Environment
|
|
|
|
Name string
|
|
Version string
|
|
}
|
|
|
|
const (
|
|
// MappedShellNames allows for custom text in place of shell names
|
|
MappedShellNames properties.Property = "mapped_shell_names"
|
|
)
|
|
|
|
func (s *Shell) Template() string {
|
|
return " {{ .Name }} "
|
|
}
|
|
|
|
func (s *Shell) Enabled() bool {
|
|
mappedNames := s.props.GetKeyValueMap(MappedShellNames, make(map[string]string))
|
|
s.Name = s.env.Shell()
|
|
s.Version = s.env.Flags().ShellVersion
|
|
for key, val := range mappedNames {
|
|
if strings.EqualFold(s.Name, key) {
|
|
s.Name = val
|
|
break
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
|
|
func (s *Shell) Init(props properties.Properties, env environment.Environment) {
|
|
s.props = props
|
|
s.env = env
|
|
}
|