mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
feat: add preset command to the shell
This commit is contained in:
parent
d881614d31
commit
8f7c8ffbfb
2 changed files with 17 additions and 9 deletions
|
|
@ -106,7 +106,10 @@ impl Executor {
|
|||
}
|
||||
"create" => cx.manager.create(),
|
||||
"rename" => cx.manager.rename(),
|
||||
"shell" => cx.manager.shell(exec.named.contains_key("block")),
|
||||
"shell" => cx.manager.shell(
|
||||
exec.named.contains_key("block"),
|
||||
exec.args.get(0).map(|s| s.as_str()).unwrap_or(""),
|
||||
),
|
||||
"hidden" => cx.manager.current_mut().hidden(match exec.args.get(0).map(|s| s.as_str()) {
|
||||
Some("show") => Some(true),
|
||||
Some("hide") => Some(false),
|
||||
|
|
|
|||
|
|
@ -225,16 +225,21 @@ impl Manager {
|
|||
|
||||
pub fn bulk_rename(&self) -> bool { false }
|
||||
|
||||
pub fn shell(&self, block: bool) -> bool {
|
||||
tokio::spawn(async move {
|
||||
let result = emit!(Input(InputOpt::top("Shell:").with_highlight()));
|
||||
pub fn shell(&self, block: bool, arg: &str) -> bool {
|
||||
let mut command = arg.to_string();
|
||||
|
||||
tokio::spawn(async move {
|
||||
if command.is_empty() {
|
||||
let result = emit!(Input(InputOpt::top("Shell:").with_highlight()));
|
||||
if let Ok(exec) = result.await {
|
||||
command = exec;
|
||||
}
|
||||
}
|
||||
|
||||
emit!(Open(
|
||||
Default::default(),
|
||||
Some(Opener { exec, block, display_name: Default::default(), spread: true })
|
||||
Some(Opener { exec: command, block, display_name: Default::default(), spread: true })
|
||||
));
|
||||
}
|
||||
});
|
||||
|
||||
false
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue