mirror of
https://github.com/FliegendeWurst/tmux-thumbs.git
synced 2024-11-22 21:05:00 +00:00
Handle better wrong executions of tmux-thumbs
This commit is contained in:
parent
674bec31fc
commit
eeb2b5f98f
@ -250,20 +250,22 @@ impl<'a> Swapper<'a> {
|
|||||||
pub fn execute_command(&mut self) {
|
pub fn execute_command(&mut self) {
|
||||||
let content = self.content.clone().unwrap();
|
let content = self.content.clone().unwrap();
|
||||||
let mut splitter = content.splitn(2, ':');
|
let mut splitter = content.splitn(2, ':');
|
||||||
let upcase = splitter.next().unwrap().trim_end();
|
|
||||||
let text = splitter.next().unwrap().trim_end();
|
|
||||||
|
|
||||||
let execute_command = if upcase == "true" {
|
if let Some(upcase) = splitter.next() {
|
||||||
self.upcase_command.clone()
|
if let Some(text) = splitter.next() {
|
||||||
} else {
|
let execute_command = if upcase.trim_end() == "true" {
|
||||||
self.command.clone()
|
self.upcase_command.clone()
|
||||||
};
|
} else {
|
||||||
|
self.command.clone()
|
||||||
|
};
|
||||||
|
|
||||||
let final_command = str::replace(execute_command.as_str(), "{}", text);
|
let final_command = str::replace(execute_command.as_str(), "{}", text.trim_end());
|
||||||
let retrieve_command = vec!["bash", "-c", final_command.as_str()];
|
let retrieve_command = vec!["bash", "-c", final_command.as_str()];
|
||||||
let params = retrieve_command.iter().map(|arg| arg.to_string()).collect();
|
let params = retrieve_command.iter().map(|arg| arg.to_string()).collect();
|
||||||
|
|
||||||
self.executor.execute(params);
|
self.executor.execute(params);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,6 +361,10 @@ fn main() -> std::io::Result<()> {
|
|||||||
let command = args.value_of("command").unwrap();
|
let command = args.value_of("command").unwrap();
|
||||||
let upcase_command = args.value_of("upcase_command").unwrap();
|
let upcase_command = args.value_of("upcase_command").unwrap();
|
||||||
|
|
||||||
|
if dir.is_empty() {
|
||||||
|
panic!("Invalid tmux-thumbs execution. Are you trying to execute tmux-thumbs directly?")
|
||||||
|
}
|
||||||
|
|
||||||
let mut executor = RealShell::new();
|
let mut executor = RealShell::new();
|
||||||
let mut swapper = Swapper::new(
|
let mut swapper = Swapper::new(
|
||||||
Box::new(&mut executor),
|
Box::new(&mut executor),
|
||||||
|
Loading…
Reference in New Issue
Block a user