mirror of
https://github.com/Ascyii/gpg.yazi.git
synced 2026-01-01 02:44:24 -05:00
36 lines
748 B
Lua
36 lines
748 B
Lua
--- @since 25.2.7
|
|
|
|
local function info(content)
|
|
return ya.notify {
|
|
title = "Gpg",
|
|
content = content,
|
|
timeout = 5,
|
|
}
|
|
end
|
|
|
|
local hovered_url = ya.sync(function()
|
|
local h = cx.active.current.hovered
|
|
return h and h.url
|
|
end)
|
|
|
|
return {
|
|
entry = function()
|
|
local hovered = hovered_url()
|
|
if not hovered then
|
|
return info("No file selected")
|
|
end
|
|
|
|
info(tostring(hovered))
|
|
|
|
local output, err = Command("gpg"):arg("--yes"):arg("--recipient"):arg("jonashahn1@gmx.net"):arg("--output"):arg(tostring(hovered) .. ".gpg"):arg("--encrypt"):arg(tostring(hovered)):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,
|
|
}
|