昨晚作了一個使人痛心疾首的操做,rm -rf something
,把我我的電腦裏的重要文件夾給刪掉了,懵逼了半天才緩過來。還好是我的文件,不對公司形成影響。這件事也讓我意識到 rm -rf
確實是個高風險操做,文件備份也是重中之重。json
爲了規避這個風險操做,我決定用 trash
替代 rm
,這樣文件就不會直接被刪除,而是進入廢紙簍。bash
trash--CLI tool that moves files or folder to the trash命令行
使用 homebrew 安裝 trash
brew install trash
code
安裝完以後在 .zshrc
或者 .bashrc
添加如下配置,.Trash
是Mac下的廢紙簍目錄。orm
alias rm=trash alias r=trash alias rl='ls ~/.Trash' alias ur=undelfile undelfile() { mv -i ~/.Trash/$@ ./ }
rm
或 r
命令能夠把文件或者文件夾移入廢紙簍。homebrew
rl
羅列出廢紙簍內的文件。get
ur
把廢紙簍內的某個文件移動到當前位置,至關於恢復。zsh