feat: support custom trash commands (#110)

This commit is contained in:
Steven Arcangeli 2023-05-23 22:32:14 -07:00
parent d27bfa1f37
commit f535c1057c
4 changed files with 26 additions and 12 deletions

View file

@ -1,9 +1,11 @@
local config = require("oil.config")
local M = {}
M.recursive_delete = function(path, cb)
local stdout = {}
local stderr = {}
local jid = vim.fn.jobstart({ "trash-put", path }, {
local cmd = vim.list_extend(vim.split(config.trash_command, "%s+"), { path })
local jid = vim.fn.jobstart(cmd, {
stdout_buffered = true,
stderr_buffered = true,
on_stdout = function(j, output)
@ -28,9 +30,9 @@ M.recursive_delete = function(path, cb)
end,
})
if jid == 0 then
cb(string.format("Passed invalid argument '%s' to 'trash-put'", path))
cb(string.format("Passed invalid argument '%s' to '%s'", path, config.trash_command))
elseif jid == -1 then
cb("'trash-put' is not executable")
cb(string.format("'%s' is not executable", config.trash_command))
end
end