fix: fd binary name detection

This commit is contained in:
Integral 2024-11-06 20:00:54 +08:00
parent 362fbebcc5
commit d5dac789b3
No known key found for this signature in database
GPG key ID: 06313911057DD5A8
3 changed files with 14 additions and 7 deletions

View file

@ -84,6 +84,7 @@ impl Actions {
writeln!(s, " magick : {}", Self::process_output("magick", "--version"))?;
writeln!(s, " fzf : {}", Self::process_output("fzf", "--version"))?;
writeln!(s, " fd : {}", Self::process_output("fd", "--version"))?;
writeln!(s, " fdfind : {}", Self::process_output("fdfind", "--version"))?;
writeln!(s, " rg : {}", Self::process_output("rg", "--version"))?;
writeln!(s, " chafa : {}", Self::process_output("chafa", "--version"))?;
writeln!(s, " zoxide : {}", Self::process_output("zoxide", "--version"))?;

View file

@ -61,7 +61,7 @@ impl Tab {
hidden,
subject: opt.subject,
args: opt.args,
})
}).await
}?;
let rx = UnboundedReceiverStream::new(rx).chunks_timeout(1000, Duration::from_millis(300));

View file

@ -1,18 +1,24 @@
use std::process::Stdio;
use anyhow::Result;
use tokio::{io::{AsyncBufReadExt, BufReader}, process::Command, sync::mpsc::{self, UnboundedReceiver}};
use tokio::{
io::{AsyncBufReadExt, BufReader},
process::Command,
sync::mpsc::{self, UnboundedReceiver},
};
use yazi_shared::fs::{File, Url};
pub struct FdOpt {
pub cwd: Url,
pub hidden: bool,
pub cwd: Url,
pub hidden: bool,
pub subject: String,
pub args: Vec<String>,
pub args: Vec<String>,
}
pub fn fd(opt: FdOpt) -> Result<UnboundedReceiver<File>> {
let mut child = Command::new("fd")
pub async fn fd(opt: FdOpt) -> Result<UnboundedReceiver<File>> {
let cmd_name = if Command::new("fd").arg("-V").status().await.is_ok() { "fd" } else { "fdfind" };
let mut child = Command::new(cmd_name)
.arg("--base-directory")
.arg(&opt.cwd)
.arg("--regex")