add plugin safe-rm to replace rm with mv

This commit is contained in:
gaoyifan 2014-04-18 00:12:58 +08:00
commit 46e5f74f3d

View file

@ -0,0 +1,16 @@
function rm () {
local files
local trash=~/.Trash/
for files in "$@"; do
# ignore any arguments
if [[ "$files" = -* ]]; then :
else
local dst=${files##*/}
# append the time if necessary
while [ -e $trash$dst ]; do
dst=$dst_$(date +%H-%M-%S)
done
/bin/mv $files $trash$dst
fi
done
}