Pick of the Week - Nov 10 [Show all picks]
Path Finder 5 - A feature-laden Finder replacement
Submit Hint Search The Forums LinksStatsPollsFAQHeadlinesRSS
12,000 hints and counting!


Click here to return to the 'A shell function to make 'rm' move files to the trash' hint
The following comments are owned by whomever posted them. This site is not responsible for what they say.
A shell function to make 'rm' move files to the trash
Authored by: CaptDeuce on Fri, Feb 29 2008 at 8:43AM PST
Open Terminal, and edit ~/.bash_profile (this is a script which is run every time you open a Terminal)

Just curious: what if you don't use the bash shell?

---
"Where's my other sock?" - A. Einstein

[ Reply to This | # ]

A shell function to make 'rm' move files to the trash
Authored by: hypert on Fri, Feb 29 2008 at 9:08AM PST
If you're using csh or tsch, add this to your .cshrc or .tcshrc file:
alias rm '\mv \!* ~/.Trash'
Feel free to call the alias "rmm" or something else that suits you. I understand the argument for doing that, but I'm too lazy to remember a million ways to call the same thing. I have an "ll" alias for "ls -l", and it's one of the WORST things, as I type "ll" all the time, even on accounts/computers. I'd rather have my alias do something instead of having me to have to re-type commands over and over. Even for "rm", as I do not accidentally delete someone else's Desktop very often...

[ Reply to This | # ]
Rewriting for tcsh, etc.
Authored by: marbx on Fri, Feb 29 2008 at 11:25AM PST
Then you'll have to figure out how to rewrite the function for tcsh, or whatever you do use. :)

Sorry, but I'm not familiar with programming in anything other than Bourne or bash, so I'm not the one to ask about it. Hypert's alias command is a basic step; and it's what I was using before I wrote this function. The added value of the function is in appending the time so you don't overwrite anything already in the trash, and in ignoring arguments (although that's not a big deal between rm and mv).

[ Reply to This | # ]