feat: support searching with the alias fdfind if fd cannot be found (#1889)

Co-authored-by: sxyazi <sxyazi@gmail.com>
This commit is contained in:
Integral 2024-11-06 20:28:12 +08:00 committed by GitHub
parent 81ce040443
commit 6001f3c619
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 25 additions and 19 deletions

View File

@ -1 +1 @@
{"flagWords":[],"words":["Punct","KEYMAP","splitn","crossterm","YAZI","unar","peekable","ratatui","syntect","pbpaste","pbcopy","ffmpegthumbnailer","oneshot","Posix","Lsar","XADDOS","zoxide","cands","Deque","precache","imageops","IFBLK","IFCHR","IFDIR","IFIFO","IFLNK","IFMT","IFSOCK","IRGRP","IROTH","IRUSR","ISGID","ISUID","ISVTX","IWGRP","IWOTH","IWUSR","IXGRP","IXOTH","IXUSR","libc","winsize","TIOCGWINSZ","xpixel","ypixel","ioerr","appender","Catppuccin","macchiato","gitmodules","Dotfiles","bashprofile","vimrc","flac","webp","exiftool","mediainfo","ripgrep","nvim","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp"," Überzug"," Überzug","Konsole","Alacritty","Überzug","pkgs","paru","unarchiver","pdftoppm","poppler","prebuild","singlefile","jpegopt","EXIF","rustfmt","mktemp","nanos","xclip","xsel","natord","Mintty","nixos","nixpkgs","SIGTSTP","SIGCONT","SIGCONT","mlua","nonstatic","userdata","metatable","natsort","backstack","luajit","Succ","Succ","cand","fileencoding","foldmethod","lightgreen","darkgray","lightred","lightyellow","lightcyan","nushell","msvc","aarch","linemode","sxyazi","rsplit","ZELLIJ","bitflags","bitflags","USERPROFILE","Neovim","vergen","gitcl","Renderable","preloaders","prec","imagesize","Upserting","prio","Ghostty","Catmull","Lanczos","cmds","unyank","scrolloff","headsup","unsub","uzers","scopeguard","SPDLOG","globset","filetime","magick","magick","prefetcher","Prework","prefetchers","PREWORKERS","conds","translit","rxvt","Urxvt","realpath","realname","REPARSE","hardlink","hardlinking","nlink","nlink","linemodes","SIGSTOP","sevenzip","rsplitn","replacen","DECSET","DECRQM","repeek","cwds","tcsi","Hyprland","Wayfire","SWAYSOCK","btime","nsec","codegen","gethostname","fchmod"],"version":"0.2","language":"en"} {"words":["Punct","KEYMAP","splitn","crossterm","YAZI","unar","peekable","ratatui","syntect","pbpaste","pbcopy","ffmpegthumbnailer","oneshot","Posix","Lsar","XADDOS","zoxide","cands","Deque","precache","imageops","IFBLK","IFCHR","IFDIR","IFIFO","IFLNK","IFMT","IFSOCK","IRGRP","IROTH","IRUSR","ISGID","ISUID","ISVTX","IWGRP","IWOTH","IWUSR","IXGRP","IXOTH","IXUSR","libc","winsize","TIOCGWINSZ","xpixel","ypixel","ioerr","appender","Catppuccin","macchiato","gitmodules","Dotfiles","bashprofile","vimrc","flac","webp","exiftool","mediainfo","ripgrep","nvim","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp"," Überzug"," Überzug","Konsole","Alacritty","Überzug","pkgs","paru","unarchiver","pdftoppm","poppler","prebuild","singlefile","jpegopt","EXIF","rustfmt","mktemp","nanos","xclip","xsel","natord","Mintty","nixos","nixpkgs","SIGTSTP","SIGCONT","SIGCONT","mlua","nonstatic","userdata","metatable","natsort","backstack","luajit","Succ","Succ","cand","fileencoding","foldmethod","lightgreen","darkgray","lightred","lightyellow","lightcyan","nushell","msvc","aarch","linemode","sxyazi","rsplit","ZELLIJ","bitflags","bitflags","USERPROFILE","Neovim","vergen","gitcl","Renderable","preloaders","prec","imagesize","Upserting","prio","Ghostty","Catmull","Lanczos","cmds","unyank","scrolloff","headsup","unsub","uzers","scopeguard","SPDLOG","globset","filetime","magick","magick","prefetcher","Prework","prefetchers","PREWORKERS","conds","translit","rxvt","Urxvt","realpath","realname","REPARSE","hardlink","hardlinking","nlink","nlink","linemodes","SIGSTOP","sevenzip","rsplitn","replacen","DECSET","DECRQM","repeek","cwds","tcsi","Hyprland","Wayfire","SWAYSOCK","btime","nsec","codegen","gethostname","fchmod","fdfind"],"version":"0.2","language":"en","flagWords":[]}

View File

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

View File

@ -22,7 +22,7 @@ impl Tab {
title: "Deprecated command".to_owned(), title: "Deprecated command".to_owned(),
content: "`select` and `select_all` command has been renamed to `toggle` and `toggle_all` in Yazi v0.4 content: "`select` and `select_all` command has been renamed to `toggle` and `toggle_all` in Yazi v0.4
Please change it in your keymap.toml, see #1773 for details: https://github.com/sxyazi/yazi/pull/1773".to_owned(), Please change it in your keymap.toml, see #1772 for details: https://github.com/sxyazi/yazi/issues/1772".to_owned(),
level: yazi_proxy::options::NotifyLevel::Error, level: yazi_proxy::options::NotifyLevel::Error,
timeout: Duration::from_secs(20), timeout: Duration::from_secs(20),
}); });

View File

@ -18,7 +18,7 @@ fn warn_deprecated(id: Option<&str>) {
}; };
let s = "The `created`, `modified`, `accessed`, `length`, and `permissions` properties of `Cha` have been renamed in Yazi v0.4. let s = "The `created`, `modified`, `accessed`, `length`, and `permissions` properties of `Cha` have been renamed in Yazi v0.4.
Please use the new `btime`, `mtime`, `atime`, `len`, and `perm` instead, in your {id}. See https://github.com/sxyazi/yazi/pull/1761 for details."; Please use the new `btime`, `mtime`, `atime`, `len`, and `perm` instead, in your {id}. See #1772 for details: https://github.com/sxyazi/yazi/issues/1772";
yazi_proxy::AppProxy::notify(yazi_proxy::options::NotifyOpt { yazi_proxy::AppProxy::notify(yazi_proxy::options::NotifyOpt {
title: "Deprecated API".to_owned(), title: "Deprecated API".to_owned(),
content: s.replace("{id}", &id), content: s.replace("{id}", &id),

View File

@ -13,9 +13,10 @@ impl Deref for Padding {
impl Padding { impl Padding {
pub fn install(lua: &Lua, ui: &Table) -> mlua::Result<()> { pub fn install(lua: &Lua, ui: &Table) -> mlua::Result<()> {
let new = lua.create_function(|_, (_, left, right, top, bottom): (Table, u16, u16, u16, u16)| { let new =
Ok(Self(ratatui::widgets::Padding::new(left, right, top, bottom))) lua.create_function(|_, (_, left, right, top, bottom): (Table, u16, u16, u16, u16)| {
})?; Ok(Self(ratatui::widgets::Padding::new(left, right, top, bottom)))
})?;
let padding = lua.create_table_from([ let padding = lua.create_table_from([
( (

View File

@ -16,7 +16,7 @@ fn warn_deprecated(id: Option<&str>) {
}; };
let s = "The `ui.Paragraph` and `ui.ListItem` elements have been deprecated in Yazi v0.4. let s = "The `ui.Paragraph` and `ui.ListItem` elements have been deprecated in Yazi v0.4.
Please use the new `ui.Text` instead, in your {id}. See https://github.com/sxyazi/yazi/pull/1776 for details."; Please use the new `ui.Text` instead, in your {id}. See #1772 for details: https://github.com/sxyazi/yazi/issues/1772";
yazi_proxy::AppProxy::notify(yazi_proxy::options::NotifyOpt { yazi_proxy::AppProxy::notify(yazi_proxy::options::NotifyOpt {
title: "Deprecated API".to_owned(), title: "Deprecated API".to_owned(),
content: s.replace("{id}", &id), content: s.replace("{id}", &id),

View File

@ -1,7 +1,7 @@
use std::process::Stdio; use std::process::Stdio;
use anyhow::Result; use anyhow::Result;
use tokio::{io::{AsyncBufReadExt, BufReader}, process::Command, sync::mpsc::{self, UnboundedReceiver}}; use tokio::{io::{AsyncBufReadExt, BufReader}, process::{Child, Command}, sync::mpsc::{self, UnboundedReceiver}};
use yazi_shared::fs::{File, Url}; use yazi_shared::fs::{File, Url};
pub struct FdOpt { pub struct FdOpt {
@ -12,17 +12,7 @@ pub struct FdOpt {
} }
pub fn fd(opt: FdOpt) -> Result<UnboundedReceiver<File>> { pub fn fd(opt: FdOpt) -> Result<UnboundedReceiver<File>> {
let mut child = Command::new("fd") let mut child = spawn("fd", &opt).or_else(|_| spawn("fdfind", &opt))?;
.arg("--base-directory")
.arg(&opt.cwd)
.arg("--regex")
.arg(if opt.hidden { "--hidden" } else { "--no-hidden" })
.args(opt.args)
.arg(opt.subject)
.kill_on_drop(true)
.stdout(Stdio::piped())
.stderr(Stdio::null())
.spawn()?;
let mut it = BufReader::new(child.stdout.take().unwrap()).lines(); let mut it = BufReader::new(child.stdout.take().unwrap()).lines();
let (tx, rx) = mpsc::unbounded_channel(); let (tx, rx) = mpsc::unbounded_channel();
@ -37,3 +27,17 @@ pub fn fd(opt: FdOpt) -> Result<UnboundedReceiver<File>> {
}); });
Ok(rx) Ok(rx)
} }
fn spawn(program: &str, opt: &FdOpt) -> std::io::Result<Child> {
Command::new(program)
.arg("--base-directory")
.arg(&opt.cwd)
.arg("--regex")
.arg(if opt.hidden { "--hidden" } else { "--no-hidden" })
.args(&opt.args)
.arg(&opt.subject)
.kill_on_drop(true)
.stdout(Stdio::piped())
.stderr(Stdio::null())
.spawn()
}