I've been bitten a few times recently with rm
ing things I shouldn't have - for example, forgetting to ulink
symlinks, not rm
them.
I'm thinking of writing a small bash script to simply move the target to ~/.local/share/Trash
, as I haven't grasped restoring files (seems to involve a lot of Linux hackery that I'm not going to achieve any time soon).
The only problems I can think of are:
- scripts/applications needing to
rm
files (really a problem? I could also get used to callingrm!
or something), - files being moved to Trash while files there already have the same name (not sure how Ubuntu get's around that at the moment, could be fixed by appending
md5(name + time())
to the name.
Of course the real answer's in backing up or just learning not to do silly things but I'd like an accommodating solution none-the-less.
Is this a really terrible idea or something that could be done?
The 'significant disadvantage' is that you'll get used to
rm
not being the big nasty, use with extreme care tool it is. This means if you ever (in your whole life, so pretty likely) use another computer not set up with this 'soft-rm' then you may userm
more carelessly, forgetting your safety net is not there.To install
trash-cli
, just type in a console:You can alias
rm
totrash-put
if you like, they have a compatible syntax. It works nicely with the gnome trash, you can recover files deleted from the command line with nautilus or the trash applet and restore files trashed from nautilus from the command line using trash-list.It will take care of different files names and remember the original location of the files too.
You can also try
gvfs-trash
, as ændrük notes in the comments. But trash-put has a couple of advantages overgvfs-trash
:1) It's not tied to gnome or gvfs. It will work even on a server without gnome or in other desktop environment. It achieves gnome compatibility because it uses the freedesktop trash spec, as gnome.
2) It tries to use the same format as rm, so it can be aliased to it. It will not fail the first time that a script tries to
trash-put -Rf dir
The main advantage of gvfs-trash is that it's installed by default in Ubuntu.