set rm to move to trash instead of perm delete

I use console a lot, and one thing i have found annoying is when i type rm -rvf it removes everything completely, or if a program executed rm function it does the same, by default I have rm    as a choice.

rmset ()
{
status=$1;
if [ “$status” == “on” ]; then
function rm ()
{
local path;
for path in “$@”;
do
if [[ “$path” = -* ]]; then
:;
else
local dst=${path##*/};
while [ -e ~/.Trash/”$dst” ]; do
dst=”$dst “$(date +%H-%M-%S);
done;
mv “$path” ~/.Trash/”$dst”;
fi;
done
};
echo “rm is set to not delete but instead mode to ~/.Trash”;
else
unset rm;
echo “rm will remove entirely skipping Trash”;
fi
}

Tags:

Leave the first comment