diff --git a/src/app.rs b/src/app.rs index add1b6d..d7f7258 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 b68d990..2d1e7ac 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, + RunShellCommand(String, String), RandomVar(i32), GoogleSearch(String), OpenPrefPane, @@ -27,8 +27,15 @@ impl Function { )); }); } - Function::RunShellCommand => { - Command::new("sh").arg("-c").arg(query).status().ok(); + Function::RunShellCommand(command, alias) => { + let query = query.to_string(); + let final_command = + format!(r#"{} {}"#, command, query.strip_prefix(alias).unwrap_or("")); + Command::new("sh") + .arg("-c") + .arg(final_command.trim()) + .spawn() + .ok(); } Function::RandomVar(var) => { Clipboard::new() diff --git a/src/config.rs b/src/config.rs index d70be14..ad93324 100644 --- a/src/config.rs +++ b/src/config.rs @@ -140,7 +140,10 @@ impl Shelly { } }); App { - open_command: Function::RunShellCommand, + open_command: Function::RunShellCommand( + self_clone.command, + self_clone.alias_lc.clone(), + ), icons: icon, name: self_clone.alias, name_lc: self_clone.alias_lc,