However, some extra security provided by safe-rm isn't a bad idea at all.Ī simple alias like rm=safe-rm -i could be enough, however rm -rf would not work, because -i is overriden by -f. This will help your brain understand what's happening and not get you into a bad habit that will cause grief later.įor me rm -i would be enough, because it prompts you before deleting any file. Just get in the habit of using the rmtrash command instead of rm. If you want to use the trash, there is nothing wrong with that. Using rm doesn't go to trash, it removes. Trying to add "trash" to commands that in the rest of the universe don't use it is a half-way step that is the worst of both worlds.Įither use the trash or don't. The proper solution is to use rm as it was meant to be used including manually adding the -i argument whenever you are in doubt about how a glob will expand, and have good system backups that you can restore in the event of serious user error.
The fundamental problem here is that even if you install a safety net on your own system, that will only help you keep your bad habits and when you happen to be on another machine some day that doesn't have the same custom protections, you will do something epicly bad. You shouldn't be in the habit of using rm at all if you can't use it properly. I strongly recommend you curb your habit of getting a little crazy.
I can think of a dozen ways to code this, but categorically refuse to type any of them up in an answer. Pop Quiz: In what directory will the rmcommand run? :) Never ever, do something like this: $ pwd Remember, this is only temporary, after a while you should remove the alias. So, whenever you use rm, you'll be prompted to either use rmtrash or /bin/rm.
alias rm="echo Use 'del', or the full path i.e. Here’s where the personal advice starts - changing one’s behavior is hard.Īnother thing you can do to force yourself to use rmtrash instead of rm is alias it to a custom message in your.
$ alias del="rmtrash" # del / trash are shorter than rmtrash So instead, install rmtrash and make a habit of using it: # install rmtrash, (either from the macports or by the brew.) Without lots of prep and qualifiers, it's a bad habit, and you need to know that. Sure, your system is safe but when you log into a friend's (or your wife's or your boss') notebook and have to delete something? You'll be actually using the real rm - deleting those files forever. Imagine, you get used to rm moving to trash and make a habit of it. Especially if your backups are not current or you don’t have the time to do an erase / install / restore. You really need control yourself when using rm. It is common and pleasuring but can be bad for you taken out of context.
Using rm to move files to the trash is a dopamine hit.