Upon accidentally running the wrong command because of an incomplete Ctrl-R
search and rm -rf
ing a file I needed, it got me thinking.
Is there a way to sanitise rm -rf foo
to be saved in bash history as rm -r foo
?
This will ensure if the command is accidentally run in the future, it will ask before doing so.
My rm
is aliased to rm -iv
, so I think this stops rm -r
from removing without asking (I admit I have not run rm -r
without the -i
flag)
The reason I think this is possible is based on the bash bang builtins.
mkdir foo
cd !$
Will show in bash history:
mkdir foo
cd foo
Edit: while I appreciate the "don't save in history at all" solutions, I am aware of it and specifically wanted a different solution, as @tripleee explained.