mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-02-21 02:55:37 -08:00
feat(session): refactor for template
This commit is contained in:
parent
f00f5f9cf7
commit
a08a3a9a21
|
@ -36,7 +36,7 @@ sidebar_label: Sample
|
|||
"leading_diamond": "\uE0B6",
|
||||
"trailing_diamond": "\uE0B0",
|
||||
"properties": {
|
||||
"postfix": " "
|
||||
"template": "{{ .UserName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -17,37 +17,26 @@ Show the current user and host name.
|
|||
"foreground": "#ffffff",
|
||||
"background": "#c386f1",
|
||||
"leading_diamond": "\uE0B6",
|
||||
"trailing_diamond": "\uE0B0"
|
||||
"trailing_diamond": "\uE0B0",
|
||||
"properties": {
|
||||
"template": "{{ .UserName }}"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
- user_info_separator: `string` - text/icon to put in between the user and host name - defaults to `@`
|
||||
- ssh_icon: `string` - text/icon to display first when in an active SSH session - defaults
|
||||
to `\uF817 `
|
||||
- user_color: `string` [color][colors] - override the foreground color of the user name
|
||||
- host_color: `string` [color][colors] - override the foreground color of the host name
|
||||
- display_user: `boolean` - display the user name or not - defaults to `true`
|
||||
- display_host: `boolean` - display the host name or not - defaults to `true`
|
||||
- default_user_name: `string` - name of the default user - defaults to empty
|
||||
- display_default: `boolean` - display the segment or not when the user matches `default_user_name` - defaults
|
||||
to `true`
|
||||
- template: `string` - A go [text/template][go-text-template] template extended with [sprig][sprig] utilizing the
|
||||
properties below. Only used when a value is set, making the above properties obsolete.
|
||||
properties below.
|
||||
|
||||
## Template Properties
|
||||
|
||||
- `.UserName`: `string` - the current user's name
|
||||
- `.DefaultUserName`: - the default user name (set with the `POSH_SESSION_DEFAULT_USER` env var or `default_user_name` property)
|
||||
- `.ComputerName`: `string` - the current computer's name
|
||||
- `.SSHSession`: `boolean` - active SSH session or not
|
||||
- `.Root`: `boolean` - are you a root/admin user or not
|
||||
|
||||
## Environmnent Variables
|
||||
|
||||
- `POSH_SESSION_DEFAULT_USER` - used to override the hardcoded `default_user_name` property
|
||||
|
||||
[colors]: /docs/config-colors
|
||||
[go-text-template]: https://golang.org/pkg/text/template/
|
||||
[sprig]: https://masterminds.github.io/sprig/
|
||||
|
|
|
@ -238,3 +238,69 @@ func (b *batt) shouldDisplay() bool {
|
|||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Session
|
||||
|
||||
const (
|
||||
// UserInfoSeparator is put between the user and computer name
|
||||
UserInfoSeparator Property = "user_info_separator"
|
||||
// UserColor if set, is used to color the user name
|
||||
UserColor Property = "user_color"
|
||||
// HostColor if set, is used to color the computer name
|
||||
HostColor Property = "host_color"
|
||||
// DisplayHost hides or show the computer name
|
||||
DisplayHost Property = "display_host"
|
||||
// DisplayUser hides or shows the user name
|
||||
DisplayUser Property = "display_user"
|
||||
// DefaultUserName holds the default user of the platform
|
||||
DefaultUserName Property = "default_user_name"
|
||||
|
||||
defaultUserEnvVar = "POSH_SESSION_DEFAULT_USER"
|
||||
)
|
||||
|
||||
func (s *session) getDefaultUser() string {
|
||||
user := s.env.getenv(defaultUserEnvVar)
|
||||
if len(user) == 0 {
|
||||
user = s.props.getString(DefaultUserName, "")
|
||||
}
|
||||
return user
|
||||
}
|
||||
|
||||
func (s *session) legacyEnabled() bool {
|
||||
if s.props.getBool(DisplayUser, true) {
|
||||
s.UserName = s.getUserName()
|
||||
}
|
||||
if s.props.getBool(DisplayHost, true) {
|
||||
s.ComputerName = s.getComputerName()
|
||||
}
|
||||
s.DefaultUserName = s.getDefaultUser()
|
||||
showDefaultUser := s.props.getBool(DisplayDefault, true)
|
||||
if !showDefaultUser && s.DefaultUserName == s.UserName {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (s *session) getFormattedText() string {
|
||||
separator := ""
|
||||
if s.props.getBool(DisplayHost, true) && s.props.getBool(DisplayUser, true) {
|
||||
separator = s.props.getString(UserInfoSeparator, "@")
|
||||
}
|
||||
var sshIcon string
|
||||
if s.SSHSession {
|
||||
sshIcon = s.props.getString(SSHIcon, "\uF817 ")
|
||||
}
|
||||
defaulColor := s.props.getColor(ForegroundOverride, "")
|
||||
userColor := s.props.getColor(UserColor, defaulColor)
|
||||
hostColor := s.props.getColor(HostColor, defaulColor)
|
||||
if len(userColor) > 0 && len(hostColor) > 0 {
|
||||
return fmt.Sprintf("%s<%s>%s</>%s<%s>%s</>", sshIcon, userColor, s.UserName, separator, hostColor, s.ComputerName)
|
||||
}
|
||||
if len(userColor) > 0 {
|
||||
return fmt.Sprintf("%s<%s>%s</>%s%s", sshIcon, userColor, s.UserName, separator, s.ComputerName)
|
||||
}
|
||||
if len(hostColor) > 0 {
|
||||
return fmt.Sprintf("%s%s%s<%s>%s</>", sshIcon, s.UserName, separator, hostColor, s.ComputerName)
|
||||
}
|
||||
return fmt.Sprintf("%s%s%s%s", sshIcon, s.UserName, separator, s.ComputerName)
|
||||
}
|
||||
|
|
|
@ -401,3 +401,198 @@ func TestBatterySegmentSingle(t *testing.T) {
|
|||
assert.Equal(t, tc.ExpectedColor, actualColor, tc.Case)
|
||||
}
|
||||
}
|
||||
|
||||
// Session
|
||||
|
||||
func TestPropertySessionSegment(t *testing.T) {
|
||||
cases := []struct {
|
||||
Case string
|
||||
ExpectedEnabled bool
|
||||
ExpectedString string
|
||||
UserName string
|
||||
Host string
|
||||
DefaultUserName string
|
||||
DefaultUserNameEnv string
|
||||
SSHSession bool
|
||||
SSHClient bool
|
||||
Root bool
|
||||
DisplayUser bool
|
||||
DisplayHost bool
|
||||
DisplayDefault bool
|
||||
HostColor string
|
||||
UserColor string
|
||||
GOOS string
|
||||
HostError bool
|
||||
}{
|
||||
{
|
||||
Case: "user and computer",
|
||||
ExpectedString: "john at company-laptop",
|
||||
Host: "company-laptop",
|
||||
DisplayUser: true,
|
||||
DisplayHost: true,
|
||||
UserName: "john",
|
||||
ExpectedEnabled: true,
|
||||
},
|
||||
{
|
||||
Case: "user and computer with host color",
|
||||
ExpectedString: "john at <yellow>company-laptop</>",
|
||||
Host: "company-laptop",
|
||||
DisplayUser: true,
|
||||
DisplayHost: true,
|
||||
UserName: "john",
|
||||
HostColor: "yellow",
|
||||
ExpectedEnabled: true,
|
||||
},
|
||||
{
|
||||
Case: "user and computer with user color",
|
||||
ExpectedString: "<yellow>john</> at company-laptop",
|
||||
Host: "company-laptop",
|
||||
DisplayUser: true,
|
||||
DisplayHost: true,
|
||||
UserName: "john",
|
||||
UserColor: "yellow",
|
||||
ExpectedEnabled: true,
|
||||
},
|
||||
{
|
||||
Case: "user and computer with both colors",
|
||||
ExpectedString: "<yellow>john</> at <green>company-laptop</>",
|
||||
Host: "company-laptop",
|
||||
DisplayUser: true,
|
||||
DisplayHost: true,
|
||||
UserName: "john",
|
||||
UserColor: "yellow",
|
||||
HostColor: "green",
|
||||
ExpectedEnabled: true,
|
||||
},
|
||||
{
|
||||
Case: "SSH Session",
|
||||
ExpectedString: "ssh john at company-laptop",
|
||||
Host: "company-laptop",
|
||||
DisplayUser: true,
|
||||
DisplayHost: true,
|
||||
UserName: "john",
|
||||
SSHSession: true,
|
||||
ExpectedEnabled: true,
|
||||
},
|
||||
{
|
||||
Case: "SSH Client",
|
||||
ExpectedString: "ssh john at company-laptop",
|
||||
Host: "company-laptop",
|
||||
DisplayUser: true,
|
||||
DisplayHost: true,
|
||||
UserName: "john",
|
||||
SSHClient: true,
|
||||
ExpectedEnabled: true,
|
||||
},
|
||||
{
|
||||
Case: "SSH Client",
|
||||
ExpectedString: "ssh john at company-laptop",
|
||||
Host: "company-laptop",
|
||||
DisplayUser: true,
|
||||
DisplayHost: true,
|
||||
UserName: "john",
|
||||
SSHClient: true,
|
||||
ExpectedEnabled: true,
|
||||
},
|
||||
{
|
||||
Case: "only user name",
|
||||
ExpectedString: "john",
|
||||
Host: "company-laptop",
|
||||
UserName: "john",
|
||||
DisplayUser: true,
|
||||
ExpectedEnabled: true,
|
||||
},
|
||||
{
|
||||
Case: "windows user name",
|
||||
ExpectedString: "john at company-laptop",
|
||||
Host: "company-laptop",
|
||||
UserName: "surface\\john",
|
||||
DisplayHost: true,
|
||||
DisplayUser: true,
|
||||
ExpectedEnabled: true,
|
||||
GOOS: string(Windows),
|
||||
},
|
||||
{
|
||||
Case: "only host name",
|
||||
ExpectedString: "company-laptop",
|
||||
Host: "company-laptop",
|
||||
UserName: "john",
|
||||
DisplayDefault: true,
|
||||
DisplayHost: true,
|
||||
ExpectedEnabled: true,
|
||||
},
|
||||
{
|
||||
Case: "display default - hidden",
|
||||
Host: "company-laptop",
|
||||
UserName: "john",
|
||||
DefaultUserName: "john",
|
||||
DisplayDefault: false,
|
||||
DisplayHost: true,
|
||||
DisplayUser: true,
|
||||
ExpectedEnabled: false,
|
||||
},
|
||||
{
|
||||
Case: "display default with env var - hidden",
|
||||
Host: "company-laptop",
|
||||
UserName: "john",
|
||||
DefaultUserNameEnv: "john",
|
||||
DefaultUserName: "jake",
|
||||
DisplayDefault: false,
|
||||
DisplayHost: true,
|
||||
DisplayUser: true,
|
||||
ExpectedEnabled: false,
|
||||
},
|
||||
{
|
||||
Case: "host error",
|
||||
ExpectedString: "john at unknown",
|
||||
Host: "company-laptop",
|
||||
HostError: true,
|
||||
UserName: "john",
|
||||
DisplayHost: true,
|
||||
DisplayUser: true,
|
||||
ExpectedEnabled: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
env := new(MockedEnvironment)
|
||||
env.On("getCurrentUser", nil).Return(tc.UserName)
|
||||
env.On("getRuntimeGOOS", nil).Return(tc.GOOS)
|
||||
if tc.HostError {
|
||||
env.On("getHostName", nil).Return(tc.Host, errors.New("oh snap"))
|
||||
} else {
|
||||
env.On("getHostName", nil).Return(tc.Host, nil)
|
||||
}
|
||||
var SSHSession string
|
||||
if tc.SSHSession {
|
||||
SSHSession = "zezzion"
|
||||
}
|
||||
var SSHClient string
|
||||
if tc.SSHClient {
|
||||
SSHClient = "clientz"
|
||||
}
|
||||
env.On("getenv", "SSH_CONNECTION").Return(SSHSession)
|
||||
env.On("getenv", "SSH_CLIENT").Return(SSHClient)
|
||||
env.On("getenv", "SSH_CLIENT").Return(SSHSession)
|
||||
env.On("getenv", defaultUserEnvVar).Return(tc.DefaultUserNameEnv)
|
||||
env.On("isRunningAsRoot", nil).Return(tc.Root)
|
||||
var props properties = map[Property]interface{}{
|
||||
UserInfoSeparator: " at ",
|
||||
SSHIcon: "ssh ",
|
||||
DefaultUserName: tc.DefaultUserName,
|
||||
DisplayDefault: tc.DisplayDefault,
|
||||
DisplayUser: tc.DisplayUser,
|
||||
DisplayHost: tc.DisplayHost,
|
||||
HostColor: tc.HostColor,
|
||||
UserColor: tc.UserColor,
|
||||
}
|
||||
session := &session{
|
||||
env: env,
|
||||
props: props,
|
||||
}
|
||||
assert.Equal(t, tc.ExpectedEnabled, session.enabled(), tc.Case)
|
||||
if tc.ExpectedEnabled {
|
||||
assert.Equal(t, tc.ExpectedString, session.string(), tc.Case)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,68 +1,51 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
import "strings"
|
||||
|
||||
type session struct {
|
||||
props properties
|
||||
env environmentInfo
|
||||
UserName string
|
||||
props properties
|
||||
env environmentInfo
|
||||
text string
|
||||
|
||||
UserName string
|
||||
ComputerName string
|
||||
SSHSession bool
|
||||
Root bool
|
||||
|
||||
DefaultUserName string
|
||||
ComputerName string
|
||||
SSHSession bool
|
||||
Root bool
|
||||
templateText string
|
||||
}
|
||||
|
||||
const (
|
||||
// UserInfoSeparator is put between the user and computer name
|
||||
UserInfoSeparator Property = "user_info_separator"
|
||||
// UserColor if set, is used to color the user name
|
||||
UserColor Property = "user_color"
|
||||
// HostColor if set, is used to color the computer name
|
||||
HostColor Property = "host_color"
|
||||
// DisplayHost hides or show the computer name
|
||||
DisplayHost Property = "display_host"
|
||||
// DisplayUser hides or shows the user name
|
||||
DisplayUser Property = "display_user"
|
||||
// SSHIcon shows when in an SSH session
|
||||
// SSHIcon is the icon used for SSH sessions
|
||||
SSHIcon Property = "ssh_icon"
|
||||
// DefaultUserName holds the default user of the platform
|
||||
DefaultUserName Property = "default_user_name"
|
||||
|
||||
defaultUserEnvVar = "POSH_SESSION_DEFAULT_USER"
|
||||
)
|
||||
|
||||
func (s *session) enabled() bool {
|
||||
s.SSHSession = s.activeSSHSession()
|
||||
segmentTemplate := s.props.getString(SegmentTemplate, "")
|
||||
if segmentTemplate == "" {
|
||||
return s.legacyEnabled()
|
||||
}
|
||||
s.UserName = s.getUserName()
|
||||
s.ComputerName = s.getComputerName()
|
||||
s.SSHSession = s.activeSSHSession()
|
||||
s.DefaultUserName = s.getDefaultUser()
|
||||
segmentTemplate := s.props.getString(SegmentTemplate, "")
|
||||
if segmentTemplate != "" {
|
||||
s.Root = s.env.isRunningAsRoot()
|
||||
template := &textTemplate{
|
||||
Template: segmentTemplate,
|
||||
Context: s,
|
||||
Env: s.env,
|
||||
}
|
||||
var err error
|
||||
s.templateText, err = template.render()
|
||||
if err != nil {
|
||||
s.templateText = err.Error()
|
||||
}
|
||||
return len(s.templateText) > 0
|
||||
s.Root = s.env.isRunningAsRoot()
|
||||
template := &textTemplate{
|
||||
Template: segmentTemplate,
|
||||
Context: s,
|
||||
Env: s.env,
|
||||
}
|
||||
showDefaultUser := s.props.getBool(DisplayDefault, true)
|
||||
if !showDefaultUser && s.DefaultUserName == s.UserName {
|
||||
return false
|
||||
var err error
|
||||
s.text, err = template.render()
|
||||
if err != nil {
|
||||
s.text = err.Error()
|
||||
}
|
||||
return true
|
||||
return len(s.text) > 0
|
||||
}
|
||||
|
||||
func (s *session) string() string {
|
||||
if len(s.text) != 0 {
|
||||
return s.text
|
||||
}
|
||||
return s.getFormattedText()
|
||||
}
|
||||
|
||||
|
@ -71,48 +54,7 @@ func (s *session) init(props properties, env environmentInfo) {
|
|||
s.env = env
|
||||
}
|
||||
|
||||
func (s *session) getFormattedText() string {
|
||||
if len(s.templateText) > 0 {
|
||||
return s.templateText
|
||||
}
|
||||
separator := ""
|
||||
if s.props.getBool(DisplayHost, true) && s.props.getBool(DisplayUser, true) {
|
||||
separator = s.props.getString(UserInfoSeparator, "@")
|
||||
}
|
||||
var sshIcon string
|
||||
if s.SSHSession {
|
||||
sshIcon = s.props.getString(SSHIcon, "\uF817 ")
|
||||
}
|
||||
defaulColor := s.props.getColor(ForegroundOverride, "")
|
||||
userColor := s.props.getColor(UserColor, defaulColor)
|
||||
hostColor := s.props.getColor(HostColor, defaulColor)
|
||||
if len(userColor) > 0 && len(hostColor) > 0 {
|
||||
return fmt.Sprintf("%s<%s>%s</>%s<%s>%s</>", sshIcon, userColor, s.UserName, separator, hostColor, s.ComputerName)
|
||||
}
|
||||
if len(userColor) > 0 {
|
||||
return fmt.Sprintf("%s<%s>%s</>%s%s", sshIcon, userColor, s.UserName, separator, s.ComputerName)
|
||||
}
|
||||
if len(hostColor) > 0 {
|
||||
return fmt.Sprintf("%s%s%s<%s>%s</>", sshIcon, s.UserName, separator, hostColor, s.ComputerName)
|
||||
}
|
||||
return fmt.Sprintf("%s%s%s%s", sshIcon, s.UserName, separator, s.ComputerName)
|
||||
}
|
||||
|
||||
func (s *session) getComputerName() string {
|
||||
if !s.props.getBool(DisplayHost, true) {
|
||||
return ""
|
||||
}
|
||||
computername, err := s.env.getHostName()
|
||||
if err != nil {
|
||||
computername = "unknown"
|
||||
}
|
||||
return strings.TrimSpace(computername)
|
||||
}
|
||||
|
||||
func (s *session) getUserName() string {
|
||||
if !s.props.getBool(DisplayUser, true) {
|
||||
return ""
|
||||
}
|
||||
user := s.env.getCurrentUser()
|
||||
username := strings.TrimSpace(user)
|
||||
if s.env.getRuntimeGOOS() == "windows" && strings.Contains(username, "\\") {
|
||||
|
@ -121,12 +63,12 @@ func (s *session) getUserName() string {
|
|||
return username
|
||||
}
|
||||
|
||||
func (s *session) getDefaultUser() string {
|
||||
user := s.env.getenv(defaultUserEnvVar)
|
||||
if len(user) == 0 {
|
||||
user = s.props.getString(DefaultUserName, "")
|
||||
func (s *session) getComputerName() string {
|
||||
computername, err := s.env.getHostName()
|
||||
if err != nil {
|
||||
computername = "unknown"
|
||||
}
|
||||
return user
|
||||
return strings.TrimSpace(computername)
|
||||
}
|
||||
|
||||
func (s *session) activeSSHSession() bool {
|
||||
|
|
|
@ -1,205 +1,11 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestPropertySessionSegment(t *testing.T) {
|
||||
cases := []struct {
|
||||
Case string
|
||||
ExpectedEnabled bool
|
||||
ExpectedString string
|
||||
UserName string
|
||||
Host string
|
||||
DefaultUserName string
|
||||
DefaultUserNameEnv string
|
||||
SSHSession bool
|
||||
SSHClient bool
|
||||
Root bool
|
||||
DisplayUser bool
|
||||
DisplayHost bool
|
||||
DisplayDefault bool
|
||||
HostColor string
|
||||
UserColor string
|
||||
GOOS string
|
||||
HostError bool
|
||||
}{
|
||||
{
|
||||
Case: "user and computer",
|
||||
ExpectedString: "john at company-laptop",
|
||||
Host: "company-laptop",
|
||||
DisplayUser: true,
|
||||
DisplayHost: true,
|
||||
UserName: "john",
|
||||
ExpectedEnabled: true,
|
||||
},
|
||||
{
|
||||
Case: "user and computer with host color",
|
||||
ExpectedString: "john at <yellow>company-laptop</>",
|
||||
Host: "company-laptop",
|
||||
DisplayUser: true,
|
||||
DisplayHost: true,
|
||||
UserName: "john",
|
||||
HostColor: "yellow",
|
||||
ExpectedEnabled: true,
|
||||
},
|
||||
{
|
||||
Case: "user and computer with user color",
|
||||
ExpectedString: "<yellow>john</> at company-laptop",
|
||||
Host: "company-laptop",
|
||||
DisplayUser: true,
|
||||
DisplayHost: true,
|
||||
UserName: "john",
|
||||
UserColor: "yellow",
|
||||
ExpectedEnabled: true,
|
||||
},
|
||||
{
|
||||
Case: "user and computer with both colors",
|
||||
ExpectedString: "<yellow>john</> at <green>company-laptop</>",
|
||||
Host: "company-laptop",
|
||||
DisplayUser: true,
|
||||
DisplayHost: true,
|
||||
UserName: "john",
|
||||
UserColor: "yellow",
|
||||
HostColor: "green",
|
||||
ExpectedEnabled: true,
|
||||
},
|
||||
{
|
||||
Case: "SSH Session",
|
||||
ExpectedString: "ssh john at company-laptop",
|
||||
Host: "company-laptop",
|
||||
DisplayUser: true,
|
||||
DisplayHost: true,
|
||||
UserName: "john",
|
||||
SSHSession: true,
|
||||
ExpectedEnabled: true,
|
||||
},
|
||||
{
|
||||
Case: "SSH Client",
|
||||
ExpectedString: "ssh john at company-laptop",
|
||||
Host: "company-laptop",
|
||||
DisplayUser: true,
|
||||
DisplayHost: true,
|
||||
UserName: "john",
|
||||
SSHClient: true,
|
||||
ExpectedEnabled: true,
|
||||
},
|
||||
{
|
||||
Case: "SSH Client",
|
||||
ExpectedString: "ssh john at company-laptop",
|
||||
Host: "company-laptop",
|
||||
DisplayUser: true,
|
||||
DisplayHost: true,
|
||||
UserName: "john",
|
||||
SSHClient: true,
|
||||
ExpectedEnabled: true,
|
||||
},
|
||||
{
|
||||
Case: "only user name",
|
||||
ExpectedString: "john",
|
||||
Host: "company-laptop",
|
||||
UserName: "john",
|
||||
DisplayUser: true,
|
||||
ExpectedEnabled: true,
|
||||
},
|
||||
{
|
||||
Case: "windows user name",
|
||||
ExpectedString: "john at company-laptop",
|
||||
Host: "company-laptop",
|
||||
UserName: "surface\\john",
|
||||
DisplayHost: true,
|
||||
DisplayUser: true,
|
||||
ExpectedEnabled: true,
|
||||
GOOS: string(Windows),
|
||||
},
|
||||
{
|
||||
Case: "only host name",
|
||||
ExpectedString: "company-laptop",
|
||||
Host: "company-laptop",
|
||||
UserName: "john",
|
||||
DisplayDefault: true,
|
||||
DisplayHost: true,
|
||||
ExpectedEnabled: true,
|
||||
},
|
||||
{
|
||||
Case: "display default - hidden",
|
||||
Host: "company-laptop",
|
||||
UserName: "john",
|
||||
DefaultUserName: "john",
|
||||
DisplayDefault: false,
|
||||
DisplayHost: true,
|
||||
DisplayUser: true,
|
||||
ExpectedEnabled: false,
|
||||
},
|
||||
{
|
||||
Case: "display default with env var - hidden",
|
||||
Host: "company-laptop",
|
||||
UserName: "john",
|
||||
DefaultUserNameEnv: "john",
|
||||
DefaultUserName: "jake",
|
||||
DisplayDefault: false,
|
||||
DisplayHost: true,
|
||||
DisplayUser: true,
|
||||
ExpectedEnabled: false,
|
||||
},
|
||||
{
|
||||
Case: "host error",
|
||||
ExpectedString: "john at unknown",
|
||||
Host: "company-laptop",
|
||||
HostError: true,
|
||||
UserName: "john",
|
||||
DisplayHost: true,
|
||||
DisplayUser: true,
|
||||
ExpectedEnabled: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
env := new(MockedEnvironment)
|
||||
env.On("getCurrentUser", nil).Return(tc.UserName)
|
||||
env.On("getRuntimeGOOS", nil).Return(tc.GOOS)
|
||||
if tc.HostError {
|
||||
env.On("getHostName", nil).Return(tc.Host, errors.New("oh snap"))
|
||||
} else {
|
||||
env.On("getHostName", nil).Return(tc.Host, nil)
|
||||
}
|
||||
var SSHSession string
|
||||
if tc.SSHSession {
|
||||
SSHSession = "zezzion"
|
||||
}
|
||||
var SSHClient string
|
||||
if tc.SSHClient {
|
||||
SSHClient = "clientz"
|
||||
}
|
||||
env.On("getenv", "SSH_CONNECTION").Return(SSHSession)
|
||||
env.On("getenv", "SSH_CLIENT").Return(SSHClient)
|
||||
env.On("getenv", "SSH_CLIENT").Return(SSHSession)
|
||||
env.On("getenv", defaultUserEnvVar).Return(tc.DefaultUserNameEnv)
|
||||
env.On("isRunningAsRoot", nil).Return(tc.Root)
|
||||
var props properties = map[Property]interface{}{
|
||||
UserInfoSeparator: " at ",
|
||||
SSHIcon: "ssh ",
|
||||
DefaultUserName: tc.DefaultUserName,
|
||||
DisplayDefault: tc.DisplayDefault,
|
||||
DisplayUser: tc.DisplayUser,
|
||||
DisplayHost: tc.DisplayHost,
|
||||
HostColor: tc.HostColor,
|
||||
UserColor: tc.UserColor,
|
||||
}
|
||||
session := &session{
|
||||
env: env,
|
||||
props: props,
|
||||
}
|
||||
assert.Equal(t, tc.ExpectedEnabled, session.enabled(), tc.Case)
|
||||
if tc.ExpectedEnabled {
|
||||
assert.Equal(t, tc.ExpectedString, session.string(), tc.Case)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSessionSegmentTemplate(t *testing.T) {
|
||||
cases := []struct {
|
||||
Case string
|
||||
|
@ -217,14 +23,14 @@ func TestSessionSegmentTemplate(t *testing.T) {
|
|||
ExpectedString: "john@company-laptop",
|
||||
ComputerName: "company-laptop",
|
||||
UserName: "john",
|
||||
Template: "{{.UserName}}{{if .ComputerName}}@{{.ComputerName}}{{end}}",
|
||||
Template: "{{.UserName}}@{{.ComputerName}}",
|
||||
ExpectedEnabled: true,
|
||||
},
|
||||
{
|
||||
Case: "user only",
|
||||
ExpectedString: "john",
|
||||
UserName: "john",
|
||||
Template: "{{.UserName}}{{if .ComputerName}}@{{.ComputerName}}{{end}}",
|
||||
Template: "{{.UserName}}",
|
||||
ExpectedEnabled: true,
|
||||
},
|
||||
{
|
||||
|
@ -272,7 +78,7 @@ func TestSessionSegmentTemplate(t *testing.T) {
|
|||
SSHSession: true,
|
||||
ComputerName: "remote",
|
||||
Root: true,
|
||||
Template: "{{if ne .DefaultUserName .UserName}}{{.UserName}}{{end}}",
|
||||
Template: "{{if ne .Env.POSH_SESSION_DEFAULT_USER .UserName}}{{.UserName}}{{end}}",
|
||||
ExpectedEnabled: true,
|
||||
},
|
||||
{
|
||||
|
@ -283,7 +89,7 @@ func TestSessionSegmentTemplate(t *testing.T) {
|
|||
SSHSession: true,
|
||||
ComputerName: "remote",
|
||||
Root: true,
|
||||
Template: "{{if ne .DefaultUserName .UserName}}{{.UserName}}{{end}}",
|
||||
Template: "{{if ne .Env.POSH_SESSION_DEFAULT_USER .UserName}}{{.UserName}}{{end}}",
|
||||
ExpectedEnabled: false,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -43,8 +43,7 @@
|
|||
"leading_diamond": "",
|
||||
"trailing_diamond": "\uE0B0",
|
||||
"properties": {
|
||||
"postfix": " ",
|
||||
"display_host": false
|
||||
"template": "{{ .UserName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -12,8 +12,7 @@
|
|||
"leading_diamond": "",
|
||||
"trailing_diamond": "\uE0B0",
|
||||
"properties": {
|
||||
"postfix": " ",
|
||||
"display_host": false
|
||||
"template": "{{ .UserName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
"trailing_diamond": "",
|
||||
"properties": {
|
||||
"prefix": "",
|
||||
"display_host": false
|
||||
"template": "{{ .UserName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -17,7 +17,10 @@
|
|||
"style": "powerline",
|
||||
"powerline_symbol": "\uE0B0",
|
||||
"foreground": "#100e23",
|
||||
"background": "#ffffff"
|
||||
"background": "#ffffff",
|
||||
"properties": {
|
||||
"template": "{{ .UserName }}@{{ .ComputerName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "path",
|
||||
|
|
|
@ -26,7 +26,10 @@
|
|||
"style": "powerline",
|
||||
"powerline_symbol": "\uE0B0",
|
||||
"foreground": "#100e23",
|
||||
"background": "#ffffff"
|
||||
"background": "#ffffff",
|
||||
"properties": {
|
||||
"template": "{{ .UserName }}@{{ .ComputerName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "path",
|
||||
|
|
|
@ -11,7 +11,10 @@
|
|||
"foreground": "#ffffff",
|
||||
"background": "#61AFEF",
|
||||
"leading_diamond": "\uE0B6",
|
||||
"trailing_diamond": "\uE0B0"
|
||||
"trailing_diamond": "\uE0B0",
|
||||
"properties": {
|
||||
"template": "{{ .UserName }}@{{ .ComputerName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "path",
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
"style": "plain",
|
||||
"foreground": "#45F1C2",
|
||||
"properties": {
|
||||
"display_host": false,
|
||||
"prefix": "\uf508 ",
|
||||
"postfix": " on"
|
||||
"postfix": " on",
|
||||
"template": "{{ .UserName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -11,11 +11,9 @@
|
|||
"type": "session",
|
||||
"style": "plain",
|
||||
"properties": {
|
||||
"user_info_separator": "<#ff5555>@</>",
|
||||
"prefix": "╭─[",
|
||||
"postfix": "]─",
|
||||
"user_color": "#ffff55",
|
||||
"host_color": "#55ff55"
|
||||
"template": "<#ffff55>{{ .UserName }}</><#ff5555>@</><#55ff55>{{ .ComputerName }}</>"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -101,7 +101,7 @@
|
|||
"properties": {
|
||||
"postfix": "",
|
||||
"prefix": " ",
|
||||
"user_info_separator": "<transparent> / </>"
|
||||
"template": "{{ .UserName }}<transparent> / </>{{ .ComputerName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -22,7 +22,10 @@
|
|||
"style": "powerline",
|
||||
"foreground": "#26C6DA",
|
||||
"background": "#546E7A",
|
||||
"powerline_symbol": "\uE0B0"
|
||||
"powerline_symbol": "\uE0B0",
|
||||
"properties": {
|
||||
"template": "{{ .UserName }}@{{ .ComputerName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "battery",
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
"foreground": "#E64747",
|
||||
"background": "#29315A",
|
||||
"properties": {
|
||||
"display_host": false,
|
||||
"postfix": "",
|
||||
"prefix": ""
|
||||
"prefix": "",
|
||||
"template": "{{ .UserName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -144,9 +144,9 @@
|
|||
"foreground": "#9B6BDF",
|
||||
"background": "#424242",
|
||||
"properties": {
|
||||
"display_host": false,
|
||||
"postfix": " \u276F",
|
||||
"prefix": ""
|
||||
"prefix": "",
|
||||
"template": "{{ .UserName }}"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
@ -13,10 +13,9 @@
|
|||
"background": "#E36464",
|
||||
"foreground": "#fff",
|
||||
"properties": {
|
||||
"user_info_separator": "",
|
||||
"display_host": false,
|
||||
"prefix": "",
|
||||
"postfix": " "
|
||||
"postfix": " ",
|
||||
"template": "{{ .UserName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -10,7 +10,10 @@
|
|||
"style": "diamond",
|
||||
"foreground": "#ffffff",
|
||||
"background": "#07585c",
|
||||
"leading_diamond": "\uE0B6"
|
||||
"leading_diamond": "\uE0B6",
|
||||
"properties": {
|
||||
"template": "{{ .UserName }}@{{ .ComputerName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "path",
|
||||
|
|
|
@ -10,10 +10,9 @@
|
|||
"style": "plain",
|
||||
"foreground": "#ffffff",
|
||||
"properties": {
|
||||
"user_info_separator": "",
|
||||
"display_host": false,
|
||||
"prefix": "<#CB4B16>┏[</>",
|
||||
"postfix": "<#CB4B16>]</>"
|
||||
"postfix": "<#CB4B16>]</>",
|
||||
"template": "{{ .UserName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
"trailing_diamond": "",
|
||||
"properties": {
|
||||
"prefix": "",
|
||||
"display_host": false
|
||||
"template": "{{ .UserName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -22,7 +22,10 @@
|
|||
{
|
||||
"type": "session",
|
||||
"style": "plain",
|
||||
"foreground": "#ffffff"
|
||||
"foreground": "#ffffff",
|
||||
"properties": {
|
||||
"template": "{{ .UserName }}@{{ .ComputerName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "path",
|
||||
|
|
|
@ -16,7 +16,10 @@
|
|||
"type": "session",
|
||||
"style": "powerline",
|
||||
"foreground": "#ffffff",
|
||||
"background": "#3A86FF"
|
||||
"background": "#3A86FF",
|
||||
"properties": {
|
||||
"template": "{{ .UserName }}@{{ .ComputerName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "path",
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
"style": "plain",
|
||||
"foreground": "#7E46B6",
|
||||
"properties": {
|
||||
"display_host": false,
|
||||
"prefix": ""
|
||||
"prefix": "",
|
||||
"template": "{{ .UserName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -10,10 +10,8 @@
|
|||
"style": "plain",
|
||||
"foreground": "#FFFFFF",
|
||||
"properties": {
|
||||
"user_info_separator": " <#ffffff>in</> ",
|
||||
"prefix": "<#0377C8># </>",
|
||||
"user_color": "#0377C8",
|
||||
"host_color": "#4A9207"
|
||||
"template": "<#0377C8>{{ .UserName }}</> <#ffffff>in</> <#4A9207>{{ .ComputerName }}</>"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -109,9 +109,7 @@
|
|||
"foreground": "#ffffff",
|
||||
"background": "#86BBD8",
|
||||
"properties": {
|
||||
"prefix": " ",
|
||||
"postfix": " ",
|
||||
"display_host": false
|
||||
"template": "{{ .UserName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -10,10 +10,9 @@
|
|||
"style": "plain",
|
||||
"foreground": "#FFE082",
|
||||
"properties": {
|
||||
"user_info_separator": "",
|
||||
"display_host": false,
|
||||
"prefix": "@",
|
||||
"postfix": " \u279C"
|
||||
"postfix": " \u279C",
|
||||
"template": "{{ .UserName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -29,8 +29,7 @@
|
|||
"background": "#003543",
|
||||
"properties": {
|
||||
"prefix": "",
|
||||
"display_host": false,
|
||||
"postfix": " "
|
||||
"template": "{{ .UserName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -12,8 +12,7 @@
|
|||
"leading_diamond": "",
|
||||
"trailing_diamond": "\uE0B0",
|
||||
"properties": {
|
||||
"postfix": " ",
|
||||
"display_host": false
|
||||
"template": "{{ .UserName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -27,7 +27,10 @@
|
|||
"foreground": "#ffffff",
|
||||
"background": "#4707a8",
|
||||
"leading_diamond": "\uE0B6",
|
||||
"trailing_diamond": "\uE0B0"
|
||||
"trailing_diamond": "\uE0B0",
|
||||
"properties": {
|
||||
"template": "{{ .UserName }}@{{ .ComputerName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "az",
|
||||
|
|
|
@ -178,8 +178,7 @@
|
|||
"foreground": "#ffffff",
|
||||
"background": "#DC291E",
|
||||
"properties": {
|
||||
"postfix": " ",
|
||||
"display_host": false
|
||||
"template": "{{ .UserName }}"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
"foreground": "#f1184c",
|
||||
"background": "#242424",
|
||||
"properties": {
|
||||
"display_host": false,
|
||||
"postfix": ""
|
||||
"postfix": "",
|
||||
"template": "{{ .UserName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
"properties": {
|
||||
"prefix": "",
|
||||
"display_host": true,
|
||||
"host_color": "#e06c75",
|
||||
"user_info_separator": "<#000000>@</>"
|
||||
"template": "{{ .UserName }}<#000000>@</><#e06c75>{{ .ComputerName }}</>"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
"trailing_diamond": "",
|
||||
"properties": {
|
||||
"prefix": "",
|
||||
"display_host": false
|
||||
"template": "{{ .UserName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -17,7 +17,10 @@
|
|||
"style": "powerline",
|
||||
"powerline_symbol": "\uE0B0",
|
||||
"foreground": "#100e23",
|
||||
"background": "#ffffff"
|
||||
"background": "#ffffff",
|
||||
"properties": {
|
||||
"template": "{{ .UserName }}@{{ .ComputerName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "path",
|
||||
|
|
|
@ -82,12 +82,8 @@
|
|||
"foreground": "#ffea00",
|
||||
"background": "#2f2f2f",
|
||||
"properties": {
|
||||
"display_host": false,
|
||||
"user_info_separator": "<#ffea00 >\uf1fa</>",
|
||||
"display_default": false,
|
||||
"user_color": "#ffea00",
|
||||
"host_color": "#2EEFBF",
|
||||
"postfix": "<#ffea00> \ue0b1</>"
|
||||
"postfix": "<#ffea00> \ue0b1</>",
|
||||
"template": "{{ if ne .Env.POSH_SESSION_DEFAULT_USER .UserName }}{{ .UserName }}{{ end }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -11,7 +11,10 @@
|
|||
"foreground": "#ff0000",
|
||||
"background": "#333333",
|
||||
"leading_diamond": "\uE0B6",
|
||||
"trailing_diamond": "\uE0B0"
|
||||
"trailing_diamond": "\uE0B0",
|
||||
"properties": {
|
||||
"template": "{{ .UserName }}@{{ .ComputerName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "spotify",
|
||||
|
|
|
@ -64,7 +64,8 @@
|
|||
"background": "#546E7A",
|
||||
"leading_diamond": "\uE0B2",
|
||||
"properties": {
|
||||
"postfix": " <#26C6DA>\uE0B3</> "
|
||||
"postfix": " <#26C6DA>\uE0B3</> ",
|
||||
"template": "{{ .UserName }}@{{ .ComputerName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -13,7 +13,10 @@
|
|||
{
|
||||
"type": "session",
|
||||
"style": "plain",
|
||||
"foreground": "#ffffff"
|
||||
"foreground": "#ffffff",
|
||||
"properties": {
|
||||
"template": "{{ .UserName }}@{{ .ComputerName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "path",
|
||||
|
|
|
@ -14,10 +14,8 @@
|
|||
"style": "plain",
|
||||
"foreground": "#BF616A",
|
||||
"properties": {
|
||||
"display_host": false,
|
||||
"display_user": true,
|
||||
"user_info_separator": "",
|
||||
"prefix": ""
|
||||
"prefix": "",
|
||||
"template": "{{ .UserName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
"trailing_diamond": "",
|
||||
"properties": {
|
||||
"prefix": "",
|
||||
"display_host": false
|
||||
"template": "{{ .UserName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -29,9 +29,8 @@
|
|||
"background": "#0A703E",
|
||||
"foreground": "#ffffff",
|
||||
"properties": {
|
||||
"display_host": false,
|
||||
"prefix": "",
|
||||
"postfix": " "
|
||||
"template": "{{ .UserName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -29,9 +29,9 @@
|
|||
"background": "#E0E0E0",
|
||||
"foreground": "#424242",
|
||||
"properties": {
|
||||
"display_host": false,
|
||||
"prefix": "",
|
||||
"postfix": ""
|
||||
"postfix": "",
|
||||
"template": "{{ .UserName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -1304,43 +1304,14 @@
|
|||
"properties": {
|
||||
"properties": {
|
||||
"properties": {
|
||||
"user_info_separator": {
|
||||
"type": "string",
|
||||
"title": "User Info Separator",
|
||||
"description": "Text/icon to put in between the user and host name",
|
||||
"default": "@"
|
||||
},
|
||||
"ssh_icon": {
|
||||
"type": "string",
|
||||
"title": "SSH Icon",
|
||||
"description": "Text/icon to display first when in an active SSH session",
|
||||
"default": "\uF817"
|
||||
},
|
||||
"user_color": { "$ref": "#/definitions/color" },
|
||||
"host_color": { "$ref": "#/definitions/color" },
|
||||
"display_user": {
|
||||
"type": "boolean",
|
||||
"title": "Display User",
|
||||
"description": "Display the user name or not",
|
||||
"default": true
|
||||
},
|
||||
"display_host": {
|
||||
"type": "boolean",
|
||||
"title": "Display Host",
|
||||
"description": "Display the host name or not",
|
||||
"default": true
|
||||
},
|
||||
"default_user_name": {
|
||||
"type": "string",
|
||||
"title": "Default User Name",
|
||||
"description": "The name of the default user",
|
||||
"default": ""
|
||||
},
|
||||
"display_default": {
|
||||
"type": "boolean",
|
||||
"title": "Display Default User",
|
||||
"description": "Display the segment when default user or not",
|
||||
"default": true
|
||||
"template": {
|
||||
"$ref": "#/definitions/template"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,11 +42,8 @@
|
|||
"foreground": "#fafafa",
|
||||
"background": "#2f2f2f",
|
||||
"properties": {
|
||||
"user_info_separator": "<#7a7a7a>\uf1fa</>",
|
||||
"display_default": false,
|
||||
"user_color": "#77f5d6",
|
||||
"host_color": "#2EEFBF",
|
||||
"postfix": "<#7a7a7a> \ue0b1</>"
|
||||
"postfix": "<#7a7a7a> \ue0b1</>",
|
||||
"template": "{{ if ne .Env.POSH_SESSION_DEFAULT_USER .UserName }}<#77f5d6>{{ .UserName }}</><#7a7a7a>\uf1fa</><#2EEFBF>{{ end }}{{ .ComputerName }}</>"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -42,11 +42,8 @@
|
|||
"foreground": "#fafafa",
|
||||
"background": "#2f2f2f",
|
||||
"properties": {
|
||||
"user_info_separator": "<#7a7a7a>\uf1fa</>",
|
||||
"display_default": false,
|
||||
"user_color": "#77f5d6",
|
||||
"host_color": "#2EEFBF",
|
||||
"postfix": "<#7a7a7a> \ue0b1</>"
|
||||
"postfix": "<#7a7a7a> \ue0b1</>",
|
||||
"template": "{{ if ne .Env.POSH_SESSION_DEFAULT_USER .UserName }}<#77f5d6>{{ .UserName }}</><#7a7a7a>\uf1fa</><#2EEFBF>{{ .ComputerName }}{{ end }}</>"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -21,7 +21,11 @@
|
|||
{
|
||||
"type": "session",
|
||||
"style": "plain",
|
||||
"foreground": "#FFFFFF"
|
||||
"foreground": "#FFFFFF",
|
||||
"properties": {
|
||||
"prefix": "",
|
||||
"template": "{{ .UserName }}@{{ .ComputerName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "path",
|
||||
|
|
|
@ -25,11 +25,8 @@
|
|||
"style": "plain",
|
||||
"foreground": "#26C6DA",
|
||||
"properties": {
|
||||
"display_host": false,
|
||||
"prefix": " ",
|
||||
"postfix": ": ",
|
||||
"user_info_separator": "",
|
||||
"display_user": true
|
||||
"template": "{{ .UserName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -16,10 +16,8 @@
|
|||
"invert_powerline": false,
|
||||
"foreground": "lightYellow",
|
||||
"properties": {
|
||||
"display_host": false,
|
||||
"prefix": "",
|
||||
"user_info_separator": "",
|
||||
"display_user": true
|
||||
"template": "{{ .UserName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
"foreground": "#757575",
|
||||
"properties": {
|
||||
"prefix": "\u250c ",
|
||||
"display_host": true
|
||||
"template": "{{ .UserName }}@{{ .ComputerName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
"type": "session",
|
||||
"style": "plain",
|
||||
"properties": {
|
||||
"prefix": ""
|
||||
"prefix": "",
|
||||
"template": "{{ .UserName }}@{{ .ComputerName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -43,10 +43,8 @@
|
|||
"type": "session",
|
||||
"style": "plain",
|
||||
"properties": {
|
||||
"user_info_separator": " <darkGray>@</> ",
|
||||
"prefix": "",
|
||||
"user_color": "cyan",
|
||||
"host_color": "green"
|
||||
"template": "<cyan>{{ .UserName }}</> <darkGray>@</> <green>{{ .ComputerName }}</>"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -10,9 +10,8 @@
|
|||
"style": "plain",
|
||||
"foreground": "#E36464",
|
||||
"properties": {
|
||||
"user_info_separator": "",
|
||||
"display_host": false,
|
||||
"prefix": "@"
|
||||
"prefix": "@",
|
||||
"template": "{{ .UserName }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue