$ trash <file>
Every rm'ed a file you needed? Of course you haven't. But I have. I got sick of it so I created a bash function. Here it is. It'll put trashed files into a $HOME/.Trash/"date" folder according to the date. I have rm aliased to it as well in my bashrc so that I still use the rm command. It'll choke if you attempt to trash a directory if that directory name is already in the Trash. This rarely happens in my case but it's easy enough to add another test and to mv the old dir if necessary.
function trash(){
if [ -z "$*" ] ; then
echo "Usage: trash filename"
else
DATE=$( date +%F )
[ -d "${HOME}/.Trash/${DATE}" ] || mkdir -p ${HOME}/.Trash/${DATE}
for FILE in $@ ; do
mv "${FILE}" "${HOME}/.Trash/${DATE}"
echo "${FILE} trashed!"
done
fi
}
by David Winterbottom (codeinthehole.com)
0sem comentários ainda