Replies: 6 comments 6 replies
|
It's not possible and maintainer has expressed no interest to implement it. |
1 reply
Override
|
0 replies
|
How would I do this on windows? |
1 reply
|
Thanks, That worked
…On Tue, Apr 15, 2025, at 22:38, Drowning Cat wrote:
I can speak for myself. In the case of my code all you need to do is to replace `local cmd = 'trash ' .. path` with a command to put into trash for Windows.
—
Reply to this email directly, view it on GitHub <#1647 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ALLYYRNLSHBNLLT7VZIOKU32ZXUGXAVCNFSM6AAAAAB2ANBIV2VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTEOBUHE4TIOA>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
1 reply
|
Here's the code for files. The problem is that it crashes on directories. So there needs to be an if statement to deal with that. It probably needs something like this |
1 reply
|
This is the code I have that works for me under actions to re-define delete to delete to trash for both Win and Linux. is_windows is a function I wrote that returns true if running on Windows.
explorer_del = function(picker)
local actions = require('snacks.explorer.actions')
local Tree = require('snacks.explorer.tree')
local paths =
vim.tbl_map(Snacks.picker.util.path, picker:selected({ fallback = true }))
if #paths == 0 then
return
end
local what = #paths == 1 and vim.fn.fnamemodify(paths[1], ':p:~:.')
or #paths .. ' files'
actions.confirm('Move ' .. what .. ' to recycle bin?', function()
for _, path in ipairs(paths) do
local cmd
local is_windows = vim.loop.os_uname().sysname == 'Windows_NT'
local stat = vim.loop.fs_stat(path)
if is_windows then
if stat and stat.type == 'directory' then
cmd = 'powershell.exe -Command "Add-Type -AssemblyName Microsoft.VisualBasic; [Microsoft.VisualBasic.FileIO.FileSystem]::DeleteDirectory(\''
.. path
.. "', 'OnlyErrorDialogs', 'SendToRecycleBin')\""
else
cmd = 'powershell.exe -Command "Add-Type -AssemblyName Microsoft.VisualBasic; [Microsoft.VisualBasic.FileIO.FileSystem]::DeleteFile(\''
.. path
.. "', 'OnlyErrorDialogs', 'SendToRecycleBin')\""
end
else
if vim.fn.executable('trash') == 1 then
cmd = 'trash "' .. path .. '"'
else
Snacks.notify.error('Missing `trash` CLI on this system')
return
end
end
local result = vim.fn.system(cmd)
if vim.v.shell_error == 0 then
Snacks.bufdelete({ file = path, force = true })
Tree:refresh(vim.fs.dirname(path))
else
Snacks.notify.error('Failed to delete `' .. path .. '`:\n- ' .. result)
end
end
picker.list:set_selected()
actions.update(picker)
end)
end,
…On Mon, Aug 25, 2025, at 12:17, Sebastian Studniczek wrote:
Is it working for you? For some reason there is no effect when I am trying to use it, but the same command pasted in cmd works fine
—
Reply to this email directly, view it on GitHub <#1647 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ALLYYRK6TUTVBNHT6GOJCT33PNOODAVCNFSM6AAAAAB2ANBIV2VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTIMRRGM4DKMI>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I really like explorer, but want to enable a key for delete to trash instead of permanently delete. I am using nvim on win 11 and Linux.
All reactions