diff --git a/pkg/webconsole/server/tty_server.go b/pkg/webconsole/server/tty_server.go index 4cf4f0757d..bde779afa8 100644 --- a/pkg/webconsole/server/tty_server.go +++ b/pkg/webconsole/server/tty_server.go @@ -99,11 +99,15 @@ func initSocketHandler(so socketio.Socket, p *session.Pty) { log.Infof("exec: %s", p.Command) args := strings.Split(p.Command, " ") cmd := exec.Command(args[0], args[1:]...) + cmd.Env = append(cmd.Env, "TERM=screen-256color") if _pty, err := pty.Start(cmd); err != nil { so.Emit(OUTPUT_EVENT, err.Error()+"\r\n") log.Errorf("exec error: %v", err) } else { p.Pty, p.Cmd, p.IsOk = _pty, cmd, true + if p.OriginSize != nil { + p.Resize(p.OriginSize) + } } } p.Buffer, data = "", "" diff --git a/pkg/webconsole/session/pty_session.go b/pkg/webconsole/session/pty_session.go index 7cb2ea8182..64c2c893f6 100644 --- a/pkg/webconsole/session/pty_session.go +++ b/pkg/webconsole/session/pty_session.go @@ -12,17 +12,18 @@ import ( ) type Pty struct { - Session *SSession - Cmd *exec.Cmd - Pty *os.File - sizeCh chan os.Signal - size *pty.Winsize - Show bool - IsOk bool - Buffer string - Output string - Command string - Exit bool + Session *SSession + Cmd *exec.Cmd + Pty *os.File + sizeCh chan os.Signal + size *pty.Winsize + OriginSize *pty.Winsize + Show bool + IsOk bool + Buffer string + Output string + Command string + Exit bool } func NewPty(session *SSession) (p *Pty, err error) { @@ -59,6 +60,7 @@ func (p *Pty) startResizeMonitor() { log.Debugf("Resize pty to %#v, cmd: %#v", p.size, p.Cmd) } } + p.OriginSize = p.size } }() }