working multisession web linux terminal
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user