working multisession web linux terminal

This commit is contained in:
2026-05-24 07:44:54 +00:00
parent 5b4803bc49
commit 63dbdf7e6a
5 changed files with 138 additions and 117 deletions
+14
View File
@@ -3,6 +3,7 @@ package internals
import (
"crypto/rand"
"fmt"
"os"
"os/exec"
"runtime"
"strings"
@@ -68,6 +69,19 @@ func getOrCreate(id string) *Session {
}
cmd.Dir = initialCwd
// Build environment: inherit parent env but force TERM so that bash readline
// correctly decodes modifier+cursor sequences (Shift+Arrow etc.).
// Without this, PTYs started from daemons/services may have TERM unset or
// set to "dumb", causing escape sequences to appear as literal characters.
env := os.Environ()
filtered := make([]string, 0, len(env)+1)
for _, e := range env {
if !strings.HasPrefix(e, "TERM=") {
filtered = append(filtered, e)
}
}
cmd.Env = append(filtered, "TERM=xterm-256color")
ptty, err := pty.Start(cmd)
if err != nil {
return nil