将rm -f or -rf 删除命令改为放入回收站,并可通过命令将其撤回

1.sudo gedit ~/.bashrc,添加如下部分

#rm -rf/f filename protected
alias rm=trash
alias r=trash
alias rl='ls /home/lijian/.local/share/Trash/files'
alias ur=undelfile

#ur recovery the files
undelfile()
{
  strpath=$(sudo cat /home/lijian/.local/share/Trash/info/*.trashinfo)
  sudo mv -i /home/lijian/.local/share/Trash/files/$@  $strpath/
  sudo rm -rf /home/lijian/.local/share/Trash/info/*
}

#rm move the files to trash
trash()
{
  trashinfo=($@'.trashinfo')
  touch /home/lijian/.local/share/Trash/info/$trashinfo
  directory=$(pwd)
  echo $directory |sudo tee /home/lijian/.local/share/Trash/info/$trashinfo
  sudo mv $@ /home/lijian/.local/share/Trash/files/
}

#cleartrash delete the files in trash
cleartrash()
{
  read -p "clear sure?[Y] or [N]" confirm
  [ $confirm == 'y' ] || [ $confirm == 'Y' ] && sudo rm -rf /home/lijian/.local/share/Trash/files/*
}

2.source ~/.bashrc 立即生效。

  • 0
    点赞
  • 1
    评论
  • 0
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

打赏
文章很值,打赏犒劳作者一下
相关推荐
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页

打赏

Seehidre

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者