diff --git a/yazi-core/src/manager/manager.rs b/yazi-core/src/manager/manager.rs index 4250eab4..f536185c 100644 --- a/yazi-core/src/manager/manager.rs +++ b/yazi-core/src/manager/manager.rs @@ -52,4 +52,7 @@ impl Manager { #[inline] pub fn selected_or_hovered(&self) -> Vec<&Url> { self.tabs.active().selected_or_hovered() } + + #[inline] + pub fn hovered_and_selected(&self) -> Vec<&Url> { self.tabs.active().hovered_and_selected() } } diff --git a/yazi-core/src/tab/commands/shell.rs b/yazi-core/src/tab/commands/shell.rs index a74ca0f0..0dadec4a 100644 --- a/yazi-core/src/tab/commands/shell.rs +++ b/yazi-core/src/tab/commands/shell.rs @@ -26,7 +26,7 @@ impl Tab { } let mut opt = opt.into() as Opt; - let selected: Vec<_> = self.selected_or_hovered().into_iter().cloned().collect(); + let selected: Vec<_> = self.hovered_and_selected().into_iter().cloned().collect(); tokio::spawn(async move { if !opt.confirm || opt.exec.is_empty() { diff --git a/yazi-core/src/tab/tab.rs b/yazi-core/src/tab/tab.rs index d354ed0b..503cee01 100644 --- a/yazi-core/src/tab/tab.rs +++ b/yazi-core/src/tab/tab.rs @@ -58,6 +58,12 @@ impl Tab { } } + pub fn hovered_and_selected(&self) -> Vec<&Url> { + let mut a = self.current.hovered().map(|h| vec![&h.url]).unwrap_or_default(); + a.extend(self.selected.iter()); + a + } + // --- History #[inline] pub fn history_new(&mut self, url: &Url) -> Folder { diff --git a/yazi-plugin/src/external/shell.rs b/yazi-plugin/src/external/shell.rs index 76d1ca73..375c85a2 100644 --- a/yazi-plugin/src/external/shell.rs +++ b/yazi-plugin/src/external/shell.rs @@ -40,8 +40,8 @@ pub fn shell(opt: ShellOpt) -> Result { .stdout(opt.stdio()) .stderr(opt.stdio()) .arg(opt.cmd) - .arg("") // $0 is the command name - .args(opt.args) + .arg(&opt.args[0]) // $0 is the hovered file + .args(&opt.args[1..]) .kill_on_drop(!opt.orphan) .pre_exec(move || { if opt.orphan && libc::setpgid(0i32, 0i32) < 0 {