-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
54 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,29 @@ | ||
local cwd = ya.sync(function() return tostring(cx.active.current.cwd) end) | ||
local state = ya.sync(function() return tostring(cx.active.current.cwd) end) | ||
|
||
local function notify(s, ...) ya.notify { title = "Fzf", content = string.format(s, ...), timeout = 5, level = "error" } end | ||
local function fail(s, ...) ya.notify { title = "Fzf", content = string.format(s, ...), timeout = 5, level = "error" } end | ||
|
||
local function entry() | ||
local _permit = ya.hide() | ||
local cwd = cwd() | ||
local cwd = state() | ||
|
||
local child, err = | ||
Command("fzf"):cwd(cwd):stdin(Command.INHERIT):stdout(Command.PIPED):stderr(Command.INHERIT):spawn() | ||
|
||
if not child then | ||
return notify("Spawn `fzf` failed with error code %s. Do you have it installed?", err) | ||
return fail("Spawn `fzf` failed with error code %s. Do you have it installed?", err) | ||
end | ||
|
||
local output, err = child:wait_with_output() | ||
if not output then | ||
return notify("`fzf` exited with error code %s", err) | ||
return fail("Cannot read `fzf` output, error code %s", err) | ||
elseif not output.status:success() and output.status:code() ~= 130 then | ||
return fail("`fzf` exited with error code %s", output.status:code()) | ||
end | ||
|
||
local target = output.stdout:gsub("\n$", "") | ||
ya.manager_emit(target:match("[/\\]$") and "cd" or "reveal", { target }) | ||
if target ~= "" then | ||
ya.manager_emit(target:match("[/\\]$") and "cd" or "reveal", { target }) | ||
end | ||
end | ||
|
||
return { entry = entry } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters