mirror of
https://github.com/Ascyii/gpg.yazi.git
synced 2026-01-01 02:44:24 -05:00
Fix?
This commit is contained in:
@@ -8,8 +8,8 @@ Setup in `init.lua` with
|
|||||||
|
|
||||||
```lua
|
```lua
|
||||||
require("gpg"):setup {
|
require("gpg"):setup {
|
||||||
default = "username@example.com",
|
default_recipient = "username@example.com",
|
||||||
delete = true,
|
delete_after = true,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
12
main.lua
12
main.lua
@@ -19,27 +19,27 @@ end)
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
setup = function(state, options)
|
setup = function(state, options)
|
||||||
state.delete = options.delete or true
|
state.delete_after = options.delete_after or true
|
||||||
state.default = options.default
|
state.default_recipient = options.default_recipient
|
||||||
end,
|
end,
|
||||||
entry = function()
|
entry = function()
|
||||||
local delete, default = get_state_attr("delete"), get_state_attr("default")
|
local delete_after, default_recipient = get_state_attr("delete_after"), get_state_attr("default_recipient")
|
||||||
local hovered = hovered_url()
|
local hovered = hovered_url()
|
||||||
if not hovered then
|
if not hovered then
|
||||||
return info("No file selected")
|
return info("No file selected")
|
||||||
end
|
end
|
||||||
|
|
||||||
if not default then
|
if not default_recipient then
|
||||||
return info("No recipient set")
|
return info("No recipient set")
|
||||||
end
|
end
|
||||||
|
|
||||||
local _, err = Command("gpg"):arg("--yes"):arg("--recipient"):arg(default):arg("--output"):arg(tostring(hovered) .. ".gpg"):arg("--encrypt"):arg(tostring(hovered)):output()
|
local _, err = Command("gpg"):arg("--yes"):arg("--recipient"):arg(default_recipient):arg("--output"):arg(tostring(hovered) .. ".gpg"):arg("--encrypt"):arg(tostring(hovered)):output()
|
||||||
if err then
|
if err then
|
||||||
return info("Failed to gpg with error: " .. err)
|
return info("Failed to gpg with error: " .. err)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Delete the plain file
|
-- Delete the plain file
|
||||||
if delete == true then
|
if delete_after == true then
|
||||||
os.remove(hovered)
|
os.remove(hovered)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user