Skip to content

Commit 5135913

Browse files
authored
Merge pull request #39 from unsecretised/variable-fix
Pass all other search args into shell commands as variables
2 parents 9260cb9 + 5d8d4d5 commit 5135913

3 files changed

Lines changed: 6 additions & 16 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 & 13 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,18 +24,8 @@ 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-
}
34-
Command::new("sh")
35-
.arg("-c")
36-
.arg(final_command)
37-
.status()
38-
.ok();
27+
Function::RunShellCommand => {
28+
Command::new("sh").arg("-c").arg(query).status().ok();
3929
}
4030
Function::RandomVar(var) => {
4131
Clipboard::new()

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)