make terminal emulator configurable

This commit is contained in:
2023-09-09 06:30:19 -07:00
parent e46c3d2b4d
commit c98a065587
10 changed files with 107 additions and 24 deletions

View File

@ -1,5 +1,4 @@
use std::net::Ipv4Addr;
use std::ffi::OsString;
use std::path::PathBuf;
use auto_launch::AutoLaunchBuilder;
@ -15,8 +14,9 @@ pub struct TermConfig {
pub name: String,
// we call it exec because it isn't always the actual path,
// in some cases it's just the name and relies on path-searching
pub exec: PathBuf,
pub args: Vec<OsString>,
// it's a string because it can come from the frontend as json
pub exec: String,
pub args: Vec<String>,
}
@ -134,18 +134,20 @@ fn default_listen_port() -> u16 {
fn default_term_config() -> TermConfig {
#[cfg(windows)]
{
if let Ok(path) = which::which("pwsh.exe") {
return TermConfig {
name: "pwsh.exe".into(),
exec: "conhost.exe".into(),
args: vec![path.into_os_string()]
};
let shell = if which::which("pwsh.exe").is_ok() {
"pwsh.exe".to_string()
}
return TermConfig {
name: "powershell.exe".into(),
exec: "conhost.exe".into(),
args: vec!["powershell.exe".into()]
else {
"powershell.exe".to_string()
};
let (exec, args) = if cfg!(debug_assertions) {
("conhost.exe".to_string(), vec![shell.clone()])
} else {
(shell.clone(), vec![])
};
TermConfig { name: shell, exec, args }
}
#[cfg(unix)]