mirror of
https://github.com/Ascyii/gpg.yazi.git
synced 2026-01-01 02:44:24 -05:00
New test
This commit is contained in:
34
main.lua
34
main.lua
@@ -1,21 +1,33 @@
|
|||||||
--- @since 25.5.31
|
--- @since 25.2.7
|
||||||
|
|
||||||
local selected_or_hovered = ya.sync(function()
|
local function info(content)
|
||||||
local tab, paths = cx.active, {}
|
return ya.notify {
|
||||||
for _, u in pairs(tab.selected) do
|
title = "Gpg",
|
||||||
paths[#paths + 1] = tostring(u)
|
content = content,
|
||||||
|
timeout = 5,
|
||||||
|
}
|
||||||
end
|
end
|
||||||
if #paths == 0 and tab.current.hovered then
|
|
||||||
paths[1] = tostring(tab.current.hovered.url)
|
local hovered_url = ya.sync(function()
|
||||||
end
|
local h = cx.active.current.hovered
|
||||||
return paths
|
return h and h.url
|
||||||
end)
|
end)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
entry = function()
|
entry = function()
|
||||||
ya.emit("escape", { visual = true })
|
local hovered = hovered_url()
|
||||||
|
if not hovered then
|
||||||
|
return info("No file selected")
|
||||||
|
end
|
||||||
|
|
||||||
return ya.notify { title = "Gpg", content = "No file selected", level = "warn", timeout = 5 }
|
local output, err = Command("gpg"):arg("--yes"):arg("--recipient"):arg("jonashahn1@gmx.net"):arg(hovered):arg("--encrypt"):arg(hovered .. ".gpg"):output()
|
||||||
|
if not output then
|
||||||
|
return info("Failed to gpg diff, error: " .. err)
|
||||||
|
end
|
||||||
|
|
||||||
|
info("Done!")
|
||||||
|
|
||||||
|
ya.clipboard(output.stdout)
|
||||||
|
info("Diff copied to clipboard")
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user