4 ms·
On any system I'm working on I add a stupid simple script named `can` that moves items to the trash can. I can't say how many times it has saved my bacon avoidi
by redman25 4y ago
On any system I'm working on I add a stupid simple script named `can` that moves items to the trash can. I can't say how many times it has saved my bacon avoiding accidental permanent deletions over using `rm`.
- pncnmnp 4y agoReally cool idea. For macOS, I just found out about trash https://formulae.brew.sh/formula/trash https://formulae.brew.sh/formula/trash
- spaboleo 4y agoOne of the few aliases I always use is: alias rm='trash -i' It will prompt you before moving files to the trash instead of deleting them straight away on macOS. I've also added the -i flag to the following: alias mv='mv -i -v' alias cp='cp -i -v' alias ln='ln -i -v' It warns me when a file might be overwritten in the target directory and will display a short protocol of the actions performed due to the 'verbose' flag.
- cywick 4y ago> alias rm='trash -i' This can really backfire. Ages ago, I used to have exactly the same alias for 'rm'. After a year or two, I got so used to 'rm' not really being destructive that one late night when I was really tired, I used it on a remote system without feeling the need to carefully check the file name. That remote system, of course, did not have 'rm' aliased to a safer version... Long story short, I strongly recommend using a different alias name (e.g., 'rem', 'rmi' or so). In this case, the worst that can happen is getting a 'command not found' message, when the alias is missing.
- spaboleo 4y agoI agree, yet I consider this to be the other way round. I treat "rm" still like a direct removal of the file and therefore use it with caution every time. Having it trash the file on my local machines is just a to me hidden fallback. But it is a very valid concern, of course.
- jamescodesthing 4y agoI use a similar thing that also handles when you forget -rf, with confirmation & stuff; https://github.com/MikeDacre/careful_rm https://github.com/MikeDacre/careful_rm