This commit is contained in:
sxyazi 2025-05-12 11:15:23 +08:00
parent 5dc4695e98
commit e13a03ce4e
No known key found for this signature in database

View file

@ -8,11 +8,9 @@ local state = ya.sync(function()
return cx.active.current.cwd, selected return cx.active.current.cwd, selected
end) end)
function M:setup(tbl) function M:setup(opts)
tbl = tbl or {} opts = opts or {}
if tbl.opts then self.args = opts.args
self.opts = table.concat(tbl.opts, " ")
end
end end
function M:entry() function M:entry()
@ -37,17 +35,14 @@ function M:entry()
end end
function M:run_with(cwd, selected) function M:run_with(cwd, selected)
local cmd = Command("fzf") local child, err = Command("fzf")
:arg("-m") :arg("-m")
:args(self.args or {})
:cwd(tostring(cwd)) :cwd(tostring(cwd))
:stdin(#selected > 0 and Command.PIPED or Command.INHERIT) :stdin(#selected > 0 and Command.PIPED or Command.INHERIT)
:stdout(Command.PIPED) :stdout(Command.PIPED)
:spawn()
if self.opts then
cmd:env("FZF_DEFAULT_OPTS", self.opts)
end
local child, err = cmd:spawn()
if not child then if not child then
return nil, Err("Failed to start `fzf`, error: %s", err) return nil, Err("Failed to start `fzf`, error: %s", err)
end end