mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
..
This commit is contained in:
parent
085c003b1b
commit
6312f17edb
4 changed files with 12 additions and 12 deletions
|
|
@ -107,9 +107,9 @@ impl Executor {
|
||||||
"create" => cx.manager.create(),
|
"create" => cx.manager.create(),
|
||||||
"rename" => cx.manager.rename(),
|
"rename" => cx.manager.rename(),
|
||||||
"shell" => cx.manager.shell(
|
"shell" => cx.manager.shell(
|
||||||
|
exec.args.get(0).map(|e| e.as_str()).unwrap_or(""),
|
||||||
exec.named.contains_key("block"),
|
exec.named.contains_key("block"),
|
||||||
exec.named.contains_key("confirm"),
|
exec.named.contains_key("confirm"),
|
||||||
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()) {
|
"hidden" => cx.manager.current_mut().hidden(match exec.args.get(0).map(|s| s.as_str()) {
|
||||||
Some("show") => Some(true),
|
Some("show") => Some(true),
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,9 @@
|
||||||
- rename: Rename a file or directory.
|
- rename: Rename a file or directory.
|
||||||
- shell: Run a shell command.
|
- shell: Run a shell command.
|
||||||
|
|
||||||
|
- `exec`: Optional, command template to be run.
|
||||||
- `--block`: Block the UI until the command finishes.
|
- `--block`: Block the UI until the command finishes.
|
||||||
|
- `--confirm`: When the template is provided, run it directly, no input UI was shown.
|
||||||
|
|
||||||
- hidden: Set the visibility of hidden files.
|
- hidden: Set the visibility of hidden files.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -225,22 +225,20 @@ impl Manager {
|
||||||
|
|
||||||
pub fn bulk_rename(&self) -> bool { false }
|
pub fn bulk_rename(&self) -> bool { false }
|
||||||
|
|
||||||
pub fn shell(&self, block: bool, confirm: bool, arg: &str) -> bool {
|
pub fn shell(&self, exec: &str, block: bool, confirm: bool) -> bool {
|
||||||
let mut command = arg.to_string();
|
let mut exec = exec.to_owned();
|
||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
if confirm || command.is_empty() {
|
if !confirm || exec.is_empty() {
|
||||||
let opt = InputOpt::top("Shell:").with_value(command.as_str()).with_highlight();
|
let result = emit!(Input(InputOpt::top("Shell:").with_value(&exec).with_highlight()));
|
||||||
let result = emit!(Input(opt));
|
match result.await {
|
||||||
|
Ok(e) => exec = e,
|
||||||
if let Ok(exec) = result.await {
|
Err(_) => return,
|
||||||
command = exec;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emit!(Open(
|
emit!(Open(
|
||||||
Default::default(),
|
Default::default(),
|
||||||
Some(Opener { exec: command, block, display_name: Default::default(), spread: true })
|
Some(Opener { exec, block, display_name: Default::default(), spread: true })
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -302,7 +302,7 @@ impl Scheduler {
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
let args = args.into_iter().map(|a| a.as_ref().to_os_string()).collect::<Vec<_>>();
|
let args = args.iter().map(|a| a.as_ref().to_os_string()).collect::<Vec<_>>();
|
||||||
tokio::spawn({
|
tokio::spawn({
|
||||||
let process = self.process.clone();
|
let process = self.process.clone();
|
||||||
let opener = opener.clone();
|
let opener = opener.clone();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue