Allow overriding default shell w/ config
This commit is contained in:
parent
2e3a8a52f7
commit
16595a6c20
|
@ -48,12 +48,18 @@ pub struct FontConfig {
|
|||
pub bold: PathBuf,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Deserialize, Serialize)]
|
||||
pub struct SystemConfig {
|
||||
pub shell: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Deserialize, Serialize)]
|
||||
pub struct Config {
|
||||
pub cursor: CursorConfig,
|
||||
pub colors: ColorConfig,
|
||||
pub draw: DrawConfig,
|
||||
pub fonts: FontConfig,
|
||||
pub system: SystemConfig,
|
||||
}
|
||||
|
||||
impl Default for CursorConfig {
|
||||
|
|
16
src/main.rs
16
src/main.rs
|
@ -42,11 +42,15 @@ impl EventListener for TermListener {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_login_shell() -> String {
|
||||
match std::env::consts::OS {
|
||||
"windows" => r#"C:\Windows\System32\cmd.exe"#.to_string(),
|
||||
"linux" | "openbsd" | "netbsd" | "dragonfly" | "solaris" | "macos" | _ =>
|
||||
std::env::var("SHELL").unwrap_or("/bin/sh".to_string())
|
||||
fn get_login_shell(config: Config) -> String {
|
||||
if config.system.shell != "" {
|
||||
config.system.shell
|
||||
} else {
|
||||
match std::env::consts::OS {
|
||||
"windows" => r#"C:\Windows\System32\cmd.exe"#.to_string(),
|
||||
"linux" | "openbsd" | "netbsd" | "dragonfly" | "solaris" | "macos" | _ =>
|
||||
std::env::var("SHELL").unwrap_or("/bin/sh".to_string())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,7 +82,7 @@ impl App {
|
|||
|
||||
let term_config = alacritty_terminal::config::Config {
|
||||
pty_config: PtyConfig {
|
||||
shell: Some(alacritty_terminal::config::Program::Just(get_login_shell())),
|
||||
shell: Some(alacritty_terminal::config::Program::Just(get_login_shell(config))),
|
||||
working_directory: None,
|
||||
hold: false,
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue