Skip to content

Instantly share code, notes, and snippets.

@puredanger
Created August 16, 2013 15:05
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save puredanger/6250711 to your computer and use it in GitHub Desktop.
Save puredanger/6250711 to your computer and use it in GitHub Desktop.
bash replacement for rm to prevent shooting yourself in the face.
function rm () {
local path
for path in "$@"; do
# ignore any arguments
if [[ "$path" = -* ]]; then :
else
local dst=${path##*/}
# append the time if necessary
while [ -e ~/.Trash/"$dst" ]; do
dst="$dst "$(date +%H-%M-%S)
done
mv "$path" ~/.Trash/"$dst"
fi
done
}
@puredanger
Copy link
Author

From my .bashrc. Shamelessly stolen from the Internet.

@djspiewak
Copy link

If you're not removing something in your home dir, this is going to cause some very strange consequences. I would suggest that if you're taking the trouble to sudo rm something, you probably mean it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment