From fe2b6ca48434d88bbd7dd360d472770286719bb7 Mon Sep 17 00:00:00 2001 From: Hojjat Date: Mon, 25 May 2026 11:16:10 -0600 Subject: [PATCH] feat: option to open new windows in the current directory --- i18n/en/cosmic_term.ftl | 4 ++-- src/main.rs | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/i18n/en/cosmic_term.ftl b/i18n/en/cosmic_term.ftl index e7d5718..686e9b5 100644 --- a/i18n/en/cosmic_term.ftl +++ b/i18n/en/cosmic_term.ftl @@ -63,8 +63,8 @@ focus-follow-mouse = Typing focus follows mouse advanced = Advanced show-headerbar = Show header show-header-description = Reveal the header from the right-click menu -tab-new-inherit-working-directory = New tabs use current directory -tab-new-inherit-working-directory-description = Open new tabs in the active tab's working directory +tab-new-inherit-working-directory = New tabs and windows use current directory +tab-new-inherit-working-directory-description = Open new tabs and windows in the active tab's working directory ### Keyboard shortcuts add-another-keybinding = Add another keybinding diff --git a/src/main.rs b/src/main.rs index e2dff69..73e0a3d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3299,12 +3299,21 @@ impl Application for App { } } Message::WindowNew => match env::current_exe() { - Ok(exe) => match process::Command::new(&exe).spawn() { - Ok(_child) => {} - Err(err) => { - log::error!("failed to execute {:?}: {}", exe, err); + Ok(exe) => { + let mut command = process::Command::new(&exe); + if self.config.tab_new_inherit_working_directory + && let Some(dir) = self.active_terminal_working_directory() + { + command.arg("--working-directory"); + command.arg(dir); } - }, + match command.spawn() { + Ok(_child) => {} + Err(err) => { + log::error!("failed to execute {:?}: {}", exe, err); + } + } + } Err(err) => { log::error!("failed to get current executable path: {}", err); }