复制内容到自己的.bashrc下
# Prevent accidental deletion #
export trash_home=/home/$USER/.trash/
# SUDO_USER可以拿到sudo前的用户名,这有时候对于打工仔想配置自己的bash可能有用处。
alias rm=del #删除
alias rl='ls $trash_home' #陈列垃圾箱
alias ur=undelfile # 恢复删除文件
alias ct=cleantrash # 清空回收站
alias RM='/bin/rm' #这个路径需要根据不同机器确定
undelfile(){
mv -i $trash_home/$@ ./
}
del(){
if [ ! -d $trash_home ];then
mkdir -p $trash_home
fi
mv $@ $trash_home
}
cleantrash(){
read -p "claer trash (Y|N):" confirm
[ $confirm == 'Y' ] || [ $confirm == 'y' ] && $RM -rfv $trash_home/*
}
参考
https://blog.csdn.net/ox0080/article/details/103197360