From b13df9054e0e90b8cb76a619b05eae0eb5a9a63c Mon Sep 17 00:00:00 2001 From: HE7086 Date: Tue, 6 Aug 2024 14:24:35 +0200 Subject: [PATCH] feat: add `cursor` option to shell command --- yazi-core/src/tab/commands/shell.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/yazi-core/src/tab/commands/shell.rs b/yazi-core/src/tab/commands/shell.rs index 05c1154a..064cc6dc 100644 --- a/yazi-core/src/tab/commands/shell.rs +++ b/yazi-core/src/tab/commands/shell.rs @@ -12,6 +12,7 @@ pub struct Opt { orphan: bool, confirm: bool, interactive: bool, + cursor: String, } impl From for Opt { @@ -22,6 +23,7 @@ impl From for Opt { orphan: c.bool("orphan"), confirm: c.bool("confirm"), interactive: c.bool("interactive"), + cursor: c.take_str("cursor").unwrap_or_default(), } } } @@ -52,10 +54,14 @@ Please replace e.g. `shell` with `shell --interactive`, `shell "my-template"` wi } let selected = self.hovered_and_selected(true).cloned().collect(); + let cursor = match opt.cursor.as_str() { + "start" => Some(0), + n => n.parse::().ok(), + }; tokio::spawn(async move { if !opt.confirm || opt.run.is_empty() { - let mut result = InputProxy::show(InputCfg::shell(opt.block).with_value(opt.run)); + let mut result = InputProxy::show(InputCfg::shell(opt.block).with_value(opt.run).with_cursor(cursor)); match result.recv().await { Some(Ok(e)) => opt.run = e, _ => return,