Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,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 whoever 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 Feb 29, '08 08:43:58AM
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 Feb 29, '08 09:08:04AM
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 Feb 29, '08 11:25:33AM

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 | # ]