Exclusive commands

Before this commit `command` and `upcase_command` where executed if you
pressed an uppercase key. This can force the user to have a innocuous
lower case command if they want to execute together.

Now they can be totally independent.
This commit is contained in:
Ferran Basora 2019-12-08 12:02:58 +01:00
parent a9c46486f1
commit f15f02c26b
2 changed files with 9 additions and 15 deletions

View File

@ -166,7 +166,7 @@ set -g @thumbs-command 'echo {} | pbcopy'
### @thumbs-upcase-command ### @thumbs-upcase-command
`default: 'tmux paste-buffer'` `default: 'tmux set-buffer {} && tmux paste-buffer'`
Choose which command execute when you press a upcase hint. `tmux-thumbs` will replace `{}` with the picked hint. Choose which command execute when you press a upcase hint. `tmux-thumbs` will replace `{}` with the picked hint.

View File

@ -93,7 +93,7 @@ fn app_args<'a>() -> clap::ArgMatches<'a> {
Arg::with_name("upcase_command") Arg::with_name("upcase_command")
.help("Upcase command") .help("Upcase command")
.long("upcase-command") .long("upcase-command")
.default_value("tmux paste-buffer"), .default_value("tmux set-buffer {} && tmux paste-buffer"),
) )
.arg( .arg(
Arg::with_name("regexp") Arg::with_name("regexp")
@ -168,19 +168,13 @@ fn main() {
exec_command(vec!["tmux", "swap-pane", "-t", pane]); exec_command(vec!["tmux", "swap-pane", "-t", pane]);
}; };
if let Some((text, paste)) = selected { if let Some((text, upcase)) = selected {
exec_command(vec![ let final_command = if upcase {
"bash", str::replace(upcase_command, "{}", text.as_str())
"-c", } else {
str::replace(command, "{}", text.as_str()).as_str(), str::replace(command, "{}", text.as_str())
]); };
if paste { exec_command(vec!["bash", "-c", final_command.as_str()]);
exec_command(vec![
"bash",
"-c",
str::replace(upcase_command, "{}", text.as_str()).as_str(),
]);
}
} }
} }