2019-03-13 04:14:30 -07:00
|
|
|
package main
|
|
|
|
|
2022-01-26 01:23:18 -08:00
|
|
|
import "oh-my-posh/environment"
|
|
|
|
|
2019-03-13 04:14:30 -07:00
|
|
|
type session struct {
|
2022-01-01 11:08:08 -08:00
|
|
|
props Properties
|
2022-01-26 01:23:18 -08:00
|
|
|
env environment.Environment
|
2022-01-22 10:46:56 -08:00
|
|
|
// text string
|
2021-12-03 14:44:58 -08:00
|
|
|
|
2022-01-17 04:16:04 -08:00
|
|
|
SSHSession bool
|
2021-12-03 14:44:58 -08:00
|
|
|
|
2021-12-04 01:22:38 -08:00
|
|
|
// Deprecated
|
2021-02-24 00:04:04 -08:00
|
|
|
DefaultUserName string
|
2019-03-13 04:14:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *session) enabled() bool {
|
2021-02-24 00:04:04 -08:00
|
|
|
s.SSHSession = s.activeSSHSession()
|
2022-01-22 10:46:56 -08:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2022-01-23 12:37:51 -08:00
|
|
|
func (s *session) template() string {
|
|
|
|
return "{{ .UserName }}@{{ .HostName }}"
|
2019-03-13 04:14:30 -07:00
|
|
|
}
|
|
|
|
|
2022-01-26 01:23:18 -08:00
|
|
|
func (s *session) init(props Properties, env environment.Environment) {
|
2019-03-13 04:14:30 -07:00
|
|
|
s.props = props
|
|
|
|
s.env = env
|
|
|
|
}
|
|
|
|
|
2020-11-03 11:06:11 -08:00
|
|
|
func (s *session) activeSSHSession() bool {
|
|
|
|
keys := []string{
|
|
|
|
"SSH_CONNECTION",
|
|
|
|
"SSH_CLIENT",
|
|
|
|
}
|
|
|
|
for _, key := range keys {
|
2022-01-23 12:37:51 -08:00
|
|
|
content := s.env.Getenv(key)
|
2020-11-03 11:06:11 -08:00
|
|
|
if content != "" {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|