mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
Draft
This commit is contained in:
parent
dc1718fcf0
commit
a84775e7c6
6 changed files with 45 additions and 7 deletions
|
|
@ -80,7 +80,8 @@ keymap = [
|
|||
{ on = [ "S" ], exec = "search rg", desc = "Search files by content using ripgrep" },
|
||||
{ on = [ "<C-s>" ], exec = "search none", desc = "Cancel the ongoing search" },
|
||||
{ on = [ "z" ], exec = "jump zoxide", desc = "Jump to a directory using zoxide" },
|
||||
{ on = [ "Z" ], exec = "jump fzf", desc = "Jump to a directory, or reveal a file using fzf" },
|
||||
{ on = [ "Z" ], exec = "jump zoxide_interactive", desc = "Jump to a directory using zoxide interactively"},
|
||||
# { on = [ " " ], exec = "jump fzf", desc = "Jump to a directory, or reveal a file using fzf" },
|
||||
|
||||
# Linemode
|
||||
{ on = [ "m", "s" ], exec = "linemode size", desc = "Set linemode to size" },
|
||||
|
|
|
|||
|
|
@ -178,6 +178,11 @@ quit_title = "{n} task{s} running, sure to quit? (y/N)"
|
|||
quit_origin = "top-center"
|
||||
quit_offset = [ 0, 2, 50, 3 ]
|
||||
|
||||
# zoxide
|
||||
zoxide_title = "Zoxide query"
|
||||
zoxide_origin = "top-center"
|
||||
zoxide_offset = [ 0, 2, 50, 3 ]
|
||||
|
||||
[select]
|
||||
open_title = "Open with:"
|
||||
open_origin = "hovered"
|
||||
|
|
|
|||
|
|
@ -59,6 +59,11 @@ pub struct Input {
|
|||
pub quit_title: String,
|
||||
pub quit_origin: Origin,
|
||||
pub quit_offset: Offset,
|
||||
|
||||
// zoxide
|
||||
pub zoxide_title: String,
|
||||
pub zoxide_origin: Origin,
|
||||
pub zoxide_offset: Offset,
|
||||
}
|
||||
|
||||
impl Default for Input {
|
||||
|
|
|
|||
|
|
@ -126,6 +126,15 @@ impl InputCfg {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn zoxide() -> Self {
|
||||
Self {
|
||||
title: INPUT.zoxide_title.to_owned(),
|
||||
position: Position::new(INPUT.zoxide_origin, INPUT.zoxide_offset),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn with_value(mut self, value: impl Into<String>) -> Self {
|
||||
self.value = value.into();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
use anyhow::anyhow;
|
||||
use yazi_config::popup::InputCfg;
|
||||
use yazi_plugin::external::{self, FzfOpt, ZoxideOpt};
|
||||
use yazi_scheduler::{Scheduler, BLOCKER};
|
||||
use yazi_shared::{event::Cmd, fs::ends_with_slash, Defer};
|
||||
|
||||
use crate::input::Input;
|
||||
use crate::tab::Tab;
|
||||
|
||||
pub struct Opt {
|
||||
|
|
@ -13,6 +16,7 @@ pub enum OptType {
|
|||
None,
|
||||
Fzf,
|
||||
Zoxide,
|
||||
ZoxideInteractive,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
|
|
@ -21,6 +25,7 @@ impl From<Cmd> for Opt {
|
|||
type_: match c.args.first().map(|s| s.as_str()) {
|
||||
Some("fzf") => OptType::Fzf,
|
||||
Some("zoxide") => OptType::Zoxide,
|
||||
Some("zoxide_interactive") => OptType::ZoxideInteractive,
|
||||
_ => OptType::None,
|
||||
},
|
||||
}
|
||||
|
|
@ -33,17 +38,28 @@ impl Tab {
|
|||
if opt.type_ == OptType::None {
|
||||
return;
|
||||
}
|
||||
|
||||
let cwd = self.current.cwd.clone();
|
||||
|
||||
tokio::spawn(async move {
|
||||
let _guard = BLOCKER.acquire().await.unwrap();
|
||||
let _defer = Defer::new(Scheduler::app_resume);
|
||||
Scheduler::app_stop().await;
|
||||
|
||||
let result = if opt.type_ == OptType::Fzf {
|
||||
external::fzf(FzfOpt { cwd }).await
|
||||
} else {
|
||||
external::zoxide(ZoxideOpt { cwd }).await
|
||||
let result = match opt.type_ {
|
||||
OptType::Fzf => external::fzf(FzfOpt { cwd }).await,
|
||||
OptType::ZoxideInteractive => external::zoxide(ZoxideOpt { cwd, query: None }).await,
|
||||
OptType::Zoxide => {
|
||||
println!("Showing input");
|
||||
let mut result = Input::_show(InputCfg::zoxide());
|
||||
|
||||
if let Some(Ok(input)) = result.recv().await {
|
||||
println!("Got input: {input}");
|
||||
external::zoxide(ZoxideOpt { cwd, query: Some(input) }).await
|
||||
} else {
|
||||
Err(anyhow!(""))
|
||||
}
|
||||
}
|
||||
_ => Err(anyhow!(""))
|
||||
};
|
||||
|
||||
let Ok(url) = result else {
|
||||
|
|
|
|||
4
yazi-plugin/src/external/zoxide.rs
vendored
4
yazi-plugin/src/external/zoxide.rs
vendored
|
|
@ -6,12 +6,14 @@ use yazi_shared::fs::Url;
|
|||
|
||||
pub struct ZoxideOpt {
|
||||
pub cwd: Url,
|
||||
pub query: Option<String>,
|
||||
}
|
||||
|
||||
pub async fn zoxide(opt: ZoxideOpt) -> Result<Url> {
|
||||
let child = Command::new("zoxide")
|
||||
.args(["query", "-i", "--exclude"])
|
||||
.args(["query", "--exclude"])
|
||||
.arg(&opt.cwd)
|
||||
.arg(if let Some(query) = &opt.query { query } else { "--interactive" })
|
||||
.kill_on_drop(true)
|
||||
.stdout(Stdio::piped())
|
||||
.spawn()?;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue