Put files/folders you delete using rm into your Mac Trash Bin.

The following addition to your .bash_profile is super handy if you regularly use the command line/console on your Mac. Instead of simply deleting files forever it will instead put them into the .Trash folder in a unique sub-folder so you can recover them until you empty your bin. Very handy if you delete something by accident!

function rm () {
local path
for path in "$@"; do
# ignore any arguments
if [[ "$path" = -* ]]; then :
else
local dst=${path##*/}
# append the time if necessary
while [ -e ~/.Trash/"$dst" ]; do
dst="$dst "$(date +%H-%M-%S)
done
mv "$path" ~/.Trash/"$dst"
fi
done
}

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

A Modern Gmail Add-on Build Process

How to inspect dynamic dropdown WebElements?

Importance of Memento Design Pattern

10 Common JavaScript Interview Questions (and Answers)

Learning to Code: Day 57 — JavaScript: ES6 Part 4

MEAN stack vs MERN stack

Build CompleteAuthentication with Bottom bar navigation in React Native

Developing API using NestJS, GraphQL & Oracle DB

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Praj Basnet

Praj Basnet

More from Medium

Mac terminal commands — Part 1

Authenticator App Two-Factor Authentication System 2022 REVIEW — MacSources

Setting up docker in macOS

How to use multiple GitHub accounts on your Mac