-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7565cd5
commit 730b6c3
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
|
||
"github.com/aymanbagabas/go-osc52" | ||
"github.com/charmbracelet/wish" | ||
"github.com/gliderlabs/ssh" | ||
) | ||
|
||
func main() { | ||
s, err := wish.NewServer( | ||
wish.WithAddress(":2222"), | ||
wish.WithHostKeyPath("ssh_host_key"), | ||
wish.WithMiddleware( | ||
middleware(), | ||
), | ||
) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
fmt.Printf("SSH into %s\n", s.Addr) | ||
s.ListenAndServe() | ||
} | ||
|
||
func middleware() wish.Middleware { | ||
return func(h ssh.Handler) ssh.Handler { | ||
return func(s ssh.Session) { | ||
environ := s.Environ() | ||
pty, _, _ := s.Pty() | ||
// Put TERM environment variable into environ. | ||
environ = append(environ, fmt.Sprintf("TERM=%s", pty.Term)) | ||
out := osc52.NewOutput(s, environ) | ||
str := "hello world" | ||
out.Copy(str) | ||
s.Write([]byte(fmt.Sprintf("Copied %q!\n", str))) | ||
} | ||
} | ||
} |