A shell function to make 'rm' move files to the trash |
|
|
Command line users: Have you ever wished rm would put stuff in the Trash instead of just deleting it? After accidentally running rm -rf Desktop one day, I decided it was time to stop really deleting stuff when I ran rm. So I wrote is a shell function -- this means that the actual /bin/rm executable works like normal; only when you run rm from Terminal do files get moved to the Trash. This means that programs (and scripts) which delete files won't be affected.
So how do you use this? Open Terminal, and edit ~/.bash_profile (this is a script which is run every time you open a Terminal). Run nano ~/.bash_profile from the command prompt if you don't have a preferred editor. Add the following lines at the bottom of the file:
function rm () {
local path
for path in "$@"; do
# ignore any arguments
if [[ "$path" = -* ]]; then :
else
local dst=&...
|