oh-my-posh/src/segment_shell.go

35 lines
655 B
Go
Raw Normal View History

2020-09-15 04:44:53 -07:00
package main
import "strings"
2020-09-15 04:44:53 -07:00
type shell struct {
props *properties
env environmentInfo
}
const (
// MappedShellNames allows for custom text in place of shell names
MappedShellNames Property = "mapped_shell_names"
)
2020-09-15 04:44:53 -07:00
func (s *shell) enabled() bool {
return true
}
func (s *shell) string() string {
mappedNames := s.props.getKeyValueMap(MappedShellNames, make(map[string]string))
shellName := s.env.getShellName()
for key, val := range mappedNames {
if strings.EqualFold(shellName, key) {
shellName = val
break
}
}
return shellName
2020-09-15 04:44:53 -07:00
}
func (s *shell) init(props *properties, env environmentInfo) {
s.props = props
s.env = env
}