mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
feat: add cursor option to shell command
This commit is contained in:
parent
52681b19e4
commit
b13df9054e
1 changed files with 7 additions and 1 deletions
|
|
@ -12,6 +12,7 @@ pub struct Opt {
|
||||||
orphan: bool,
|
orphan: bool,
|
||||||
confirm: bool,
|
confirm: bool,
|
||||||
interactive: bool,
|
interactive: bool,
|
||||||
|
cursor: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Cmd> for Opt {
|
impl From<Cmd> for Opt {
|
||||||
|
|
@ -22,6 +23,7 @@ impl From<Cmd> for Opt {
|
||||||
orphan: c.bool("orphan"),
|
orphan: c.bool("orphan"),
|
||||||
confirm: c.bool("confirm"),
|
confirm: c.bool("confirm"),
|
||||||
interactive: c.bool("interactive"),
|
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 selected = self.hovered_and_selected(true).cloned().collect();
|
||||||
|
let cursor = match opt.cursor.as_str() {
|
||||||
|
"start" => Some(0),
|
||||||
|
n => n.parse::<usize>().ok(),
|
||||||
|
};
|
||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
if !opt.confirm || opt.run.is_empty() {
|
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 {
|
match result.recv().await {
|
||||||
Some(Ok(e)) => opt.run = e,
|
Some(Ok(e)) => opt.run = e,
|
||||||
_ => return,
|
_ => return,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue