将linux下的rm命令改造成移动文件至回收站

3710 2019-03-19 11:18

今天升级jpress直接删了原来的root文件夹,吓我一跳,幸亏我把attachment文件夹ln到了其他挂载盘。

为了避免再次愚蠢,更改了rm命令。

cd ~

cat >> .bashrc <<EOF

alias rm=trash
alias rl='ls ~/.trash'
alias ur=undelfile
alias mcls=cleartrash

undelfile()
{
  mv -i ~/.trash/$@ ./
}

trash()
{
  mv $@ ~/.trash/
}

cleartrash()
{
   read -p "clear sure?[n]" confirm
   [ $confirm == 'y' ] || [ $confirm == 'Y' ] && /bin/rm -rf ~/.trash/*
}

EOF

全部评论

·