You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update: After the fix, it is working now. FZF searches over selected folders recursively, and if you don't select any, FZF searches the current directory. When you select multiple items in fzf, they will be opened in new yazi tabs when returned.
However, you can't see them all at once. I need to work further on the code to open them in new tabs or a search result pane, like the native rg or fd result pane, so the following questions:
I currently use tab_create and tabs for the selected multiple items in fzf. What is the API to show all the results in rd or fd search result pane? Where should I look at to find these API?
I use a shell pipeline to connect fd and fzf; are there any other ways to do so and better?
Try it by putting the following in ~/.config/yazi/plugins/fzfn.yazi/main.lua and define a keymap in keymap.toml.
local M = {}
-- Use ya instead of direct internal access
local state = ya.sync(function()
local selected = {}
for _, url in pairs(cx.active.selected) do
selected[#selected + 1] = url
end
return cx.active.current.cwd, selected
end)
function M:entry()
local permit = ya.hide()
local cwd, selected = state()
local output, err = M.run_with(cwd, selected)
if permit then
permit:drop()
end
if not output then
return ya.notify { title = "Fzf", content = tostring(err), timeout = 5, level = "error" }
end
local urls = M.split_urls(cwd, output)
if #urls == 0 then
return
else
for i = 1, #urls do
local cha = fs.cha(urls[i])
ya.emit("tab_create", { })
ya.emit(cha and cha.is_dir and "cd" or "reveal", { urls[i], raw = true })
end
end
end
function M.run_with(cwd, selected)
if #selected == 0 then
-- No selection - use default directory search
local child, err = Command("fzf"):arg("-m"):cwd(tostring(cwd)):stdin(Command.INHERIT):stdout(Command.PIPED):spawn()
if not child then
return nil, "Failed to start fzf: " .. tostring(err)
end
local output, err = child:wait_with_output()
if not output then
return nil, "Cannot read fzf output: " .. tostring(err)
elseif not output.status.success and output.status.code ~= 130 then
return nil, "fzf exited with code " .. tostring(output.status.code)
end
return output.stdout, nil
else
-- Selection - use shell pipeline for proper streaming
local shell_cmd = "fd . -H --full-path "
for _, u in ipairs(selected) do
shell_cmd = shell_cmd .. "'" .. tostring(u) .. "' "
end
shell_cmd = shell_cmd .. " | fzf -m"
local child = Command("sh"):arg("-c"):arg(shell_cmd):stdout(Command.PIPED):spawn()
if not child then
return nil, "Failed to start pipeline: " .. tostring(err)
end
local output, err = child:wait_with_output()
if not output then
return nil, "Cannot read pipeline output: " .. tostring(err)
elseif not output.status.success and output.status.code ~= 130 then
return nil, "Pipeline exited with code " .. tostring(output.status.code)
end
return output.stdout, nil
end
end
function M.split_urls(cwd, output)
if not output or output == "" then return {} end
local t = {}
for line in output:gmatch("[^\r\n]+") do
if line ~= "" then
local u = Url(line)
if u.is_absolute then
t[#t + 1] = u
else
t[#t + 1] = cwd:join(u)
end
end
end
return t
end
return M
I am implementing this for the RGA. Yazi's preview can preview the whole PDF page by page, so I am wondering: is it possible for Yazi preview to take the page number and line number of the PDF and highlight the searched string when you hover over the search results in the search result pane (the one used by default by fd and rg) of Yazi?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Update: After the fix, it is working now. FZF searches over selected folders recursively, and if you don't select any, FZF searches the current directory. When you select multiple items in fzf, they will be opened in new yazi tabs when returned.
However, you can't see them all at once. I need to work further on the code to open them in new tabs or a search result pane, like the native rg or fd result pane, so the following questions:
Try it by putting the following in
~/.config/yazi/plugins/fzfn.yazi/main.luaand define a keymap in keymap.toml.I am implementing this for the RGA. Yazi's preview can preview the whole PDF page by page, so I am wondering: is it possible for Yazi preview to take the page number and line number of the PDF and highlight the searched string when you hover over the search results in the search result pane (the one used by default by fd and rg) of Yazi?
Beta Was this translation helpful? Give feedback.
All reactions