From d4ab1bcfd4c152c0550d886683edb649d475850d Mon Sep 17 00:00:00 2001 From: unsecretised Date: Sun, 21 Dec 2025 21:28:55 +0800 Subject: [PATCH 1/2] Pass all other search args into shell commands as variables --- src/app.rs | 4 ++-- src/commands.rs | 12 +++--------- src/config.rs | 2 +- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/app.rs b/src/app.rs index f58fb17..add1b6d 100644 --- a/src/app.rs +++ b/src/app.rs @@ -431,7 +431,7 @@ impl Tile { let mut exact: Vec = filter_vec .par_iter() .filter(|x| match &x.open_command { - Function::RunShellCommand(_) => x + Function::RunShellCommand => x .name_lc .starts_with(query.split_once(" ").unwrap_or((&query, "")).0), _ => x.name_lc == query, @@ -442,7 +442,7 @@ impl Tile { let mut prefix: Vec = filter_vec .par_iter() .filter(|x| match x.open_command { - Function::RunShellCommand(_) => false, + Function::RunShellCommand => false, _ => x.name_lc != query && x.name_lc.starts_with(&query), }) .cloned() diff --git a/src/commands.rs b/src/commands.rs index 892804a..121c754 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -9,7 +9,7 @@ use crate::config::Config; #[derive(Debug, Clone)] pub enum Function { OpenApp(String), - RunShellCommand(String), + RunShellCommand, RandomVar(i32), GoogleSearch(String), OpenPrefPane, @@ -24,16 +24,10 @@ impl Function { &objc2_foundation::NSString::from_str(path), )); } - Function::RunShellCommand(shell_command) => { - let mut final_command = shell_command.to_owned(); - - for (argument_num, argument) in query.split_whitespace().enumerate() { - final_command = - final_command.replace(&format!("$var{}", argument_num), argument); - } + Function::RunShellCommand => { Command::new("sh") .arg("-c") - .arg(final_command) + .arg(query) .status() .ok(); } diff --git a/src/config.rs b/src/config.rs index df670a9..d70be14 100644 --- a/src/config.rs +++ b/src/config.rs @@ -140,7 +140,7 @@ impl Shelly { } }); App { - open_command: Function::RunShellCommand(self_clone.command), + open_command: Function::RunShellCommand, icons: icon, name: self_clone.alias, name_lc: self_clone.alias_lc, From 5d8d4d5fbf9a83b160dd26f4af42b3523b211b72 Mon Sep 17 00:00:00 2001 From: unsecretised Date: Sun, 21 Dec 2025 21:33:27 +0800 Subject: [PATCH 2/2] Cargo formatting --- src/commands.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index 121c754..2fe8fce 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -25,11 +25,7 @@ impl Function { )); } Function::RunShellCommand => { - Command::new("sh") - .arg("-c") - .arg(query) - .status() - .ok(); + Command::new("sh").arg("-c").arg(query).status().ok(); } Function::RandomVar(var) => { Clipboard::new()