Safe way to get "rm dir -rf" working (place options after dir name like on linux)
I don't know how many times I've done it. I'll type in rm dir
and then have to move the cursor back and add in -rf
to the command. Probably 10,000.
In linux, I can just add the options in after the dir name.
Is there any good bash magic that will let this safely happen? Here is a non-functional prototype of a simple bash rm
function that I think would do the trick:
function rm() {
if $2 eq "-rf" then run "builtin rm $2 $1"
}
But before I reinvent the wheel, I wanted to see if there were other options I'm missing. Thanks.
Solution 1:
You can install the GNU version of rm
with brew install coreutils
. It will install into /usr/local/bin/grm
to avoid conflicts with the standard version. But you can easily overcome this by aliasing it to rm
for interactive shells.