When a file is deleted using ranger, it’s permanent. Instead, if you would like to delete files to Trash, then you can do that using trash-cli
.
sudo pacman -Syu trash-cli
The tool we are interested in is trash-put which deletes a file to the Trash. The Trash directory is usually ~/.local/share/Trash. Any key can be mapped in Ranger to this command for deletion.
For example, to map the Del key to delete to Trash, add this to your ~/.config/ranger/rc.conf
:
map <DELETE> shell -s trash-put %s
Source: https://codeyarns.com/tech/2014-09-22-how-to-use-trash-cli-with-ranger.html#gsc.tab=0
To add a keybind that moves files to your trash directory ~/.local/share/Trash/files/ with DD, amend the configuration file as follows:
~/.config/ranger/rc.conf
...
map DD shell mv %s /home/${USER}/.local/share/Trash/files/
...
Alternatively, use GIO commandline tool provided by glib2 package:
map DD shell gio trash %s
(I used map dD
to overwrite standard one.)
Inspecting and emptying the “trash” is normally supported by graphical file managers such as nautilus, but you can also see the trash with the command gio list trash://, and empty it with: gio trash –empty.
Source: https://wiki.archlinux.org/title/Ranger#Move_to_trash