Skip to content

Commit d4ab1bc

Browse files
committed
Pass all other search args into shell commands as variables
1 parent 9260cb9 commit d4ab1bc

3 files changed

Lines changed: 6 additions & 12 deletions

File tree

src/app.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ impl Tile {
431431
let mut exact: Vec<App> = filter_vec
432432
.par_iter()
433433
.filter(|x| match &x.open_command {
434-
Function::RunShellCommand(_) => x
434+
Function::RunShellCommand => x
435435
.name_lc
436436
.starts_with(query.split_once(" ").unwrap_or((&query, "")).0),
437437
_ => x.name_lc == query,
@@ -442,7 +442,7 @@ impl Tile {
442442
let mut prefix: Vec<App> = filter_vec
443443
.par_iter()
444444
.filter(|x| match x.open_command {
445-
Function::RunShellCommand(_) => false,
445+
Function::RunShellCommand => false,
446446
_ => x.name_lc != query && x.name_lc.starts_with(&query),
447447
})
448448
.cloned()

src/commands.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::config::Config;
99
#[derive(Debug, Clone)]
1010
pub enum Function {
1111
OpenApp(String),
12-
RunShellCommand(String),
12+
RunShellCommand,
1313
RandomVar(i32),
1414
GoogleSearch(String),
1515
OpenPrefPane,
@@ -24,16 +24,10 @@ impl Function {
2424
&objc2_foundation::NSString::from_str(path),
2525
));
2626
}
27-
Function::RunShellCommand(shell_command) => {
28-
let mut final_command = shell_command.to_owned();
29-
30-
for (argument_num, argument) in query.split_whitespace().enumerate() {
31-
final_command =
32-
final_command.replace(&format!("$var{}", argument_num), argument);
33-
}
27+
Function::RunShellCommand => {
3428
Command::new("sh")
3529
.arg("-c")
36-
.arg(final_command)
30+
.arg(query)
3731
.status()
3832
.ok();
3933
}

src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl Shelly {
140140
}
141141
});
142142
App {
143-
open_command: Function::RunShellCommand(self_clone.command),
143+
open_command: Function::RunShellCommand,
144144
icons: icon,
145145
name: self_clone.alias,
146146
name_lc: self_clone.alias_lc,

0 commit comments

Comments
 (0)