Make 'rm' move files to the trash instead
From Tech-Wiki
More actions
Use this function to move files to ~/.Trash instead of deleting them immediately with rm.
Add the function to ~/.bash_profile.
Override rm to move files to the Trash
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
}