Skip to content
Discussion options

You must be logged in to vote

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…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by prosoitos
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
1. Q&A
Labels
None yet
2 participants