Spawn sessions with login shell terminal env
This commit is contained in:
+12
-1
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user