...
1 package main
2
3 import (
4 "fmt"
5 "log"
6
7 "github.com/aymanbagabas/go-osc52"
8 "github.com/charmbracelet/wish"
9 "github.com/gliderlabs/ssh"
10 )
11
12 func main() {
13 s, err := wish.NewServer(
14 wish.WithAddress(":2222"),
15 wish.WithHostKeyPath("ssh_host_key"),
16 wish.WithMiddleware(
17 middleware(),
18 ),
19 )
20 if err != nil {
21 log.Fatal(err)
22 }
23 fmt.Printf("SSH into %s\n", s.Addr)
24 s.ListenAndServe()
25 }
26
27 func middleware() wish.Middleware {
28 return func(h ssh.Handler) ssh.Handler {
29 return func(s ssh.Session) {
30 environ := s.Environ()
31 pty, _, _ := s.Pty()
32
33 environ = append(environ, fmt.Sprintf("TERM=%s", pty.Term))
34 out := osc52.NewOutput(s, environ)
35 str := "hello world"
36 out.Copy(str)
37 s.Write([]byte(fmt.Sprintf("Copied %q!\n", str)))
38 }
39 }
40 }
41
View as plain text