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
+1 -1
View File
@@ -445,7 +445,7 @@ retransmit_window = 256
default_input_mode = "read-write" default_input_mode = "read-write"
prewarm_sessions = ["default"] prewarm_sessions = ["default"]
create_on_attach = true create_on_attach = true
shell = "/bin/sh" shell = "/usr/bin/zsh"
sessions_dir = "~/.local/share/dosh/sessions" sessions_dir = "~/.local/share/dosh/sessions"
secret_path = "~/.config/dosh/secret" secret_path = "~/.config/dosh/secret"
``` ```
+7 -1
View File
@@ -152,6 +152,12 @@ fi
if [ "$role" = "server" ] || [ "$role" = "both" ]; then if [ "$role" = "server" ] || [ "$role" = "both" ]; then
server_config="$config_dir/server.toml" server_config="$config_dir/server.toml"
if [ "$force_config" -eq 1 ] || [ ! -f "$server_config" ]; then if [ "$force_config" -eq 1 ] || [ ! -f "$server_config" ]; then
login_shell="$(
if command -v getent >/dev/null 2>&1; then
getent passwd "$(id -un)" | awk -F: '{print $7}'
fi
)"
login_shell="${login_shell:-${SHELL:-/bin/sh}}"
cat >"$server_config" <<EOF cat >"$server_config" <<EOF
port = $port port = $port
bind = "0.0.0.0" bind = "0.0.0.0"
@@ -164,7 +170,7 @@ retransmit_window = 256
default_input_mode = "read-write" default_input_mode = "read-write"
prewarm_sessions = ["default"] prewarm_sessions = ["default"]
create_on_attach = true create_on_attach = true
shell = "/bin/sh" shell = "$login_shell"
sessions_dir = "~/.local/share/dosh/sessions" sessions_dir = "~/.local/share/dosh/sessions"
secret_path = "~/.config/dosh/secret" secret_path = "~/.config/dosh/secret"
EOF EOF
+12 -1
View File
@@ -1,6 +1,7 @@
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use portable_pty::{CommandBuilder, MasterPty, NativePtySystem, PtySize, PtySystem}; use portable_pty::{CommandBuilder, MasterPty, NativePtySystem, PtySize, PtySystem};
use std::io::{Read, Write}; use std::io::{Read, Write};
use std::path::Path;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use std::thread; use std::thread;
use tokio::sync::mpsc; use tokio::sync::mpsc;
@@ -51,7 +52,17 @@ pub fn spawn_pty_session(
pixel_height: 0, pixel_height: 0,
}) })
.context("open pty")?; .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")?; let _child = pair.slave.spawn_command(cmd).context("spawn shell")?;
drop(pair.slave); drop(pair.slave);