-
What system are you running Yazi on?Linux X11 What terminal are you running Yazi in?wezterm 20240203-110809-5046fc22
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I'm still learning, so someone else might be able to give you better feedback. But for the use case you described, I would write something like this: local function fail(s, ...)
ya.notify { title = "my_plugin_name", content = string.format(s, ...), timeout = 5, level = "error" }
end
local function entry(_)
local _permit = ya.hide()
local cmd_args = "fd -d 1 | fzf"
local child, err = Command("sh")
:args({ "-c", cmd_args })
:stdin(Command.INHERIT)
:stdout(Command.PIPED)
:stderr(Command.PIPED)
:spawn()
if not child then
return fail("Spawn command failed with error code %s.", err)
end
local output, err = child:wait_with_output()
if not output then
return fail("Cannot read command output, error code %s", err)
elseif not output.status.success and output.status.code ~= 130 then
return fail("Spawn command exited with error code %s", output.status.code)
end
local target = output.stdout:gsub("\n$", "")
if target ~= "" then
local is_dir = target:sub(-1) == "/"
ya.manager_emit(is_dir and "cd" or "reveal", { target })
end
end
return { entry = entry } Please note that |
Beta Was this translation helpful? Give feedback.
-
Ah cool! Thank you very much lpnh! I truly appreciate your time. Good idea to pass the piped commands as arguments to I will give this a try. |
Beta Was this translation helpful? Give feedback.
-
This works beautifully!!! Thank you again! ❤️ |
Beta Was this translation helpful? Give feedback.
I'm still learning, so someone else might be able to give you better feedback. But for the use case you described, I would write something like this: