diff --git a/pkg/shell.go b/pkg/shell.go index 60ff84f8..d966092c 100644 --- a/pkg/shell.go +++ b/pkg/shell.go @@ -24,9 +24,23 @@ type ShellRequest struct { PodName string `url:"pod_name,omitempty"` ContainerName string `url:"container_name,omitempty"` Command []string `url:"command"` + TtyWidth uint16 `url:"tty_width"` + TtyHeight uint16 `url:"tty_height"` } func ExecShell(req *ShellRequest) { + currentConsole := console.Current() + defer func() { + _ = currentConsole.Reset() + }() + + winSize, err := currentConsole.Size() + if err != nil { + log.Fatal("Cannot get terminal size", err) + } + req.TtyWidth = winSize.Width + req.TtyHeight = winSize.Height + wsConn, err := createWebsocketConn(req) if err != nil { log.Fatal("error while creating websocket connection", err) @@ -37,11 +51,6 @@ func ExecShell(req *ShellRequest) { } }() - currentConsole := console.Current() - defer func() { - _ = currentConsole.Reset() - }() - if err := currentConsole.SetRaw(); err != nil { log.Fatal("error while setting up console", err) }