diff --git a/segment_shell.go b/segment_shell.go index 48bd9333..0b119a50 100644 --- a/segment_shell.go +++ b/segment_shell.go @@ -1,5 +1,7 @@ package main +import "strings" + type shell struct { props *properties env environmentInfo @@ -15,7 +17,8 @@ func (s *shell) string() string { if err != nil { return "unknown" } - return p.Executable() + shell := strings.Replace(p.Executable(), ".exe", "", 1) + return shell } func (s *shell) init(props *properties, env environmentInfo) { diff --git a/segment_shell_test.go b/segment_shell_test.go index 0cb8df27..bfe93133 100755 --- a/segment_shell_test.go +++ b/segment_shell_test.go @@ -42,7 +42,22 @@ func TestWriteCurrentShell(t *testing.T) { env: env, props: props, } - assert.Equal(t, "zsh", s.string()) + assert.Equal(t, expected, s.string()) +} + +func TestWriteCurrentShellWindowsExe(t *testing.T) { + expected := "pwsh" + env := new(MockedEnvironment) + process := new(process) + parentProcess := expected + ".exe" + process.On("Executable", nil).Return(parentProcess) + env.On("getParentProcess", nil).Return(process, nil) + props := &properties{} + s := &shell{ + env: env, + props: props, + } + assert.Equal(t, expected, s.string()) } func TestWriteCurrentShellError(t *testing.T) {