Linux rm指令刪除文件到回收站

一不小心把新寫的code全刪了,幸好修改的東西不多花了一個小時又改回來了。


所以:

rm -rf 還是不要用了

能用git管理的code絕對不能偷懶


這也說明非常有必要將rm指令改爲刪除到回收站。但是發現網上的大多數方法是自己給rm起別名來實現,寫了一大堆shell,太不優雅了(笑)。

實際上,只要安裝一個很小很強大的工具就足夠了:https://github.com/andreafrancia/trash-cli

安裝:

sudo apt-get install trash-cli

trash-cli提供的指令非常簡潔:

trash-put           trashes files and directories.
trash-empty         empty the trashcan(s).
trash-list          list trashed file.
trash-restore       restore a trashed file.
trash-rm            remove individual files from trash can.

最後一個問題是:是否有必要將rm改別名爲trash-put呢?

我的觀點與作者一致,沒必要:這隻會帶來誤會和一坨沒必要的參數(-r -f -R)。

所以就按照作者的建議在.profile里加了一條提示,然後source之:

alias rm='echo "rm is disabled by harryz, use trash-put instead."; false'

P.S. 順便發現了source ~/.profile能夠修復在SecureCRT裏color theme無效的問題

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章