File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -5,13 +5,16 @@ import (
5
5
"io"
6
6
"net"
7
7
"os"
8
+ "os/signal"
8
9
"strings"
10
+ "syscall"
9
11
"time"
10
12
11
13
"github.com/google/uuid"
12
14
"github.com/mattn/go-isatty"
13
15
"github.com/spf13/cobra"
14
16
gossh "golang.org/x/crypto/ssh"
17
+ "golang.org/x/crypto/ssh/terminal"
15
18
"golang.org/x/term"
16
19
"golang.org/x/xerrors"
17
20
@@ -134,6 +137,21 @@ func ssh() *cobra.Command {
134
137
defer func () {
135
138
_ = term .Restore (int (os .Stdin .Fd ()), state )
136
139
}()
140
+
141
+ windowSize := make (chan os.Signal , 1 )
142
+ signal .Notify (windowSize , syscall .SIGWINCH )
143
+ defer signal .Stop (windowSize )
144
+ go func () {
145
+ for {
146
+ select {
147
+ case <- cmd .Context ().Done ():
148
+ return
149
+ case <- windowSize :
150
+ }
151
+ width , height , _ := terminal .GetSize (int (stdoutFile .Fd ()))
152
+ _ = sshSession .WindowChange (height , width )
153
+ }
154
+ }()
137
155
}
138
156
139
157
err = sshSession .RequestPty ("xterm-256color" , 128 , 128 , gossh.TerminalModes {})
You can’t perform that action at this time.
0 commit comments