Spawn sessions with login shell terminal env
ci / test (push) Has been cancelled
ci / remote-bench (push) Has been cancelled

This commit is contained in:
Codex
2026-06-11 09:34:56 -04:00
parent babfb204c3
commit 92f43df046
3 changed files with 20 additions and 3 deletions
+12 -1
View File
@@ -1,6 +1,7 @@
use anyhow::{Context, Result};
use portable_pty::{CommandBuilder, MasterPty, NativePtySystem, PtySize, PtySystem};
use std::io::{Read, Write};
use std::path::Path;
use std::sync::{Arc, Mutex};
use std::thread;
use tokio::sync::mpsc;
@@ -51,7 +52,17 @@ pub fn spawn_pty_session(
pixel_height: 0,
})
.context("open pty")?;
let cmd = CommandBuilder::new(shell);
let mut cmd = CommandBuilder::new(shell);
cmd.env("TERM", "xterm-256color");
cmd.env("COLORTERM", "truecolor");
cmd.env("SHELL", shell);
if let Some(home) = dirs::home_dir() {
cmd.env("HOME", home.as_os_str());
cmd.env("PWD", home.as_os_str());
cmd.cwd(home.as_os_str());
} else if let Some(parent) = Path::new(shell).parent() {
cmd.env("PWD", parent.as_os_str());
}
let _child = pair.slave.spawn_command(cmd).context("spawn shell")?;
drop(pair.slave);