I just created alias rm="rm -I"
to prevent from accidental rm
command.
-I prompt once before removing more than three files, or when removing recursively.
Less intrusive than -i, while still giving protection against most mistakes
But it doesn't work. I don't get any prompt when I use rm -rf
If you read the help again you'll see it says previous
--interactive
. This means you can add an-I
after all the other arguments (like at the end of the line) and it'll be honoured again!To do that, you need a function instead of an alias, but just stick this somewhere in your
.bashrc
(et al) and you're golden:A perhaps safer method than even this is using
trash-cli
'strash-put
command. It will put things in your account's trash directory that can be reviewed/restored/emptied normally. It also has dummy-r
,-f
and,-i
arguments so it makes a perfect alias possible:The problem here is that
-f
makesrm
ignore any interactive command:Source:
info coreutils 'rm invocation'