diff --git a/crates/terminal/src/terminal.rs b/crates/terminal/src/terminal.rs index 8172b56485..032a750d1a 100644 --- a/crates/terminal/src/terminal.rs +++ b/crates/terminal/src/terminal.rs @@ -371,35 +371,48 @@ impl TerminalBuilder { release_channel::AppVersion::global(cx).to_string(), ); - let mut terminal_title_override = None; + #[derive(Default)] + struct ShellParams { + program: String, + args: Option>, + title_override: Option, + } + + let shell_params = match shell.clone() { + Shell::System => { + #[cfg(target_os = "windows")] + { + Some(ShellParams { + program: util::get_windows_system_shell(), + ..Default::default() + }) + } + #[cfg(not(target_os = "windows"))] + None + } + Shell::Program(program) => Some(ShellParams { + program, + ..Default::default() + }), + Shell::WithArguments { + program, + args, + title_override, + } => Some(ShellParams { + program, + args: Some(args), + title_override, + }), + }; + let terminal_title_override = shell_params.as_ref().and_then(|e| e.title_override.clone()); + + #[cfg(windows)] + let shell_program = shell_params.as_ref().map(|params| params.program.clone()); let pty_options = { - let alac_shell = match shell.clone() { - Shell::System => { - #[cfg(target_os = "windows")] - { - Some(alacritty_terminal::tty::Shell::new( - util::get_windows_system_shell(), - Vec::new(), - )) - } - #[cfg(not(target_os = "windows"))] - { - None - } - } - Shell::Program(program) => { - Some(alacritty_terminal::tty::Shell::new(program, Vec::new())) - } - Shell::WithArguments { - program, - args, - title_override, - } => { - terminal_title_override = title_override; - Some(alacritty_terminal::tty::Shell::new(program, args)) - } - }; + let alac_shell = shell_params.map(|params| { + alacritty_terminal::tty::Shell::new(params.program, params.args.unwrap_or_default()) + }); alacritty_terminal::tty::Options { shell: alac_shell, @@ -503,6 +516,8 @@ impl TerminalBuilder { python_venv_directory, last_mouse_move_time: Instant::now(), last_hyperlink_search_position: None, + #[cfg(windows)] + shell_program, }; Ok(TerminalBuilder { @@ -663,6 +678,8 @@ pub struct Terminal { is_ssh_terminal: bool, last_mouse_move_time: Instant, last_hyperlink_search_position: Option>, + #[cfg(windows)] + shell_program: Option, } pub struct TaskState { @@ -708,6 +725,20 @@ impl Terminal { fn process_event(&mut self, event: AlacTermEvent, cx: &mut Context) { match event { AlacTermEvent::Title(title) => { + // ignore default shell program title change as windows always sends those events + // and it would end up showing the shell executable path in breadcrumbs + #[cfg(windows)] + { + if self + .shell_program + .as_ref() + .map(|e| *e == title) + .unwrap_or(false) + { + return; + } + } + self.breadcrumb_text = title; cx.emit(Event::BreadcrumbsChanged); }