saferm (2004)

A long time ago, back in college, when the vast majority of my time was spent in the Terminal, I would get burned time after time, having rm’d something that I later ended up needing, or after accidentally having rm’d something important. At the same time I was falling deeply in love with Mac OS X’s UI and its forgiving Trash concept. So I decided to build a guardrail for myself and aliased rm to a script that replicates the functionality of Trash.


saferm.tcsh (view it here in github)

  • Ignores -r and -f switches (why bother if files are just moved to Trash)

  • If a file/folder (say, “photo.jpg”) with the same name already exists in the Trash, it is renamed to “photo copy.jpg”. If that name also exists, it is renamed to “photo copy 1.jpg” etc.

Then simply in my .bash_profile I added

alias rm="~/saferm.tcsh"

You’ll thank me later.