Skip to content

Commit

Permalink
fix: use correct shell on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
cfoust committed Aug 21, 2024
1 parent d30d56a commit 0269a3a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/cy/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ func (c *Cy) NewClient(ctx context.Context, options ClientOptions) (*Client, err
return nil, err
}

client.params.SetParent(c.tree.Root().Params())

c.Lock()
c.clients = append(c.clients, client)
c.Unlock()
Expand Down
33 changes: 33 additions & 0 deletions pkg/cy/cy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import (

"github.com/cfoust/cy/pkg/cy/cmd"
"github.com/cfoust/cy/pkg/geom"
T "github.com/cfoust/cy/pkg/mux/screen/tree"
"github.com/cfoust/cy/pkg/mux/stream"
"github.com/cfoust/cy/pkg/replay"

"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -85,3 +87,34 @@ func TestClients(t *testing.T) {
clients[i].Cancel()
}
}

func TestDefaultShell(t *testing.T) {
ctx := context.Background()
cy, err := Start(ctx, Options{
Shell: "/bin/zsh",
})
require.NoError(t, err)

client, err := cy.NewClient(ctx, ClientOptions{
Env: map[string]string{
"TERM": "xterm-256color",
},
Size: geom.DEFAULT_SIZE,
})
require.NoError(t, err)

node := client.Node()
require.NotNil(t, node)

pane, ok := node.(*T.Pane)
require.True(t, ok)

r, ok := pane.Screen().(*replay.Replayable)
require.True(t, ok)

cmd, ok := r.Cmd().(*stream.Cmd)
require.True(t, ok)

options := cmd.Options()
require.Equal(t, "/bin/zsh", options.Command)
}
5 changes: 5 additions & 0 deletions pkg/mux/stream/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ func (c *Cmd) Resize(size Size) error {
})
}

// Options returns the original arguments used to start the command.
func (c *Cmd) Options() CmdOptions {
return c.options
}

func (c *Cmd) Path() (string, error) {
c.RLock()
proc := c.proc
Expand Down

0 comments on commit 0269a3a

Please sign in to comment.