Skip to content

Instantly share code, notes, and snippets.

@Sfinx
Last active July 17, 2022 11:07
Show Gist options
  • Save Sfinx/76a92648e7cf8c071087958847933e92 to your computer and use it in GitHub Desktop.
Save Sfinx/76a92648e7cf8c071087958847933e92 to your computer and use it in GitHub Desktop.
Simple bashrc protection for accidental "rm *"
rm_protect() {
for i in "$@"
do
if [ "$i" = '*' ] ;then
echo -n "Are you sure [rm * in $PWD] ? "
read j
if [ "$j" != y ]; then return; fi
fi
done
set +f
bash -c "/bin/rm $*"
}
alias rm='set -f; rm_protect'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment