440Forums  |  MacMusic.org  |  PcMusic.org  |  440tv  |  Zicos  |  AudioLexic
you   {key13}


A shell function to make 'rm' move files to the trash

MacOsxHints

Friday February 29, 2008. 04:30 PM
MacOsxHints

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=&...
Command line users Have ever wished would stuff Trash instead just deleting shell function make
A shell function to make Read more at MacOsxHints
feeds.macosxhints.com/~r/macosxhints/recent/~3/243382289/article.php

 

 Related News 
Rapid and Centrify make corporate Mac move Rapid and Centrify make corporate Mac move
 Macworld UK 03/12/08 11 AM 
Apple files trademark application for ?thinnovation? Apple files trademark application for ?thinnovation?
 Mac Daily News 03/11/08 09 PM 
iGame Radio Reviews Make Bouncy Bouncy iGame Radio Reviews Make Bouncy Bouncy
 InsideMacGames 03/10/08 02 PM 
0KB of disk space available even after deleting files (follow-up) 0KB of disk space available even after deleting files (follow-up)
 MacFixIt 03/07/08 07 PM 
iPhone 1.1.4 update hacked, make your iPhone vibrate and then... iPhone 1.1.4 update hacked, make your iPhone vibrate and then...
 Low End Mac 03/07/08 07 PM 
iD Software, Freeverse make play for iPhone iD Software, Freeverse make play for iPhone
 Macworld UK 03/07/08 11 AM 
Enclose lets you attach files without size limits Enclose lets you attach files without size limits
 Mac Central 03/06/08 04 PM 
Gracion Enclose 1.0 Released - Mac Users Transfer Files w... Gracion Enclose 1.0 Released - Mac Users Transfer Files w...
 AppleLinks 03/06/08 06 AM 
Apple files iMac, iPod shuffle trademarks Apple files iMac, iPod shuffle trademarks
 MacNN 03/05/08 09 PM 
0KB of disk space available, even after deleting files 0KB of disk space available, even after deleting files
 MacFixIt 03/05/08 08 PM 
iPodObserver - Facebook Considers Move into iTunes Market iPodObserver - Facebook Considers Move into iTunes Market
 TheMacObserver 03/05/08 03 PM 
How Much Money Do You Make when Selling Music on iTunes Store? How Much Money Do You Make when Selling Music on iTunes Store?
 Mac Bidouille 03/04/08 10 AM 
Compress Files In Any Format Directly From The Finder Compress Files In Any Format Directly From The Finder
 AppleLinks 03/04/08 07 AM 
Compress Files '08 Adds Contextual Menu Support Compress Files '08 Adds Contextual Menu Support
 TheMacObserver 03/03/08 05 PM 
Trent Reznor in Radiohead-like album sale move Trent Reznor in Radiohead-like album sale move
 Macworld UK 03/03/08 11 AM 
10.5: AppleScript 'path to me' function changed in 10.5 10.5: AppleScript 'path to me' function changed in 10.5
 MacOsxHints 02/28/08 04 PM 
10.5: Share files and create sharing users in one step 10.5: Share files and create sharing users in one step
 MacOsxHints 02/27/08 04 PM 
Research firms: Hollywood need not let Apple make all of the ... Research firms: Hollywood need not let Apple make all of the ...
 Mac Daily News 02/26/08 11 PM 
Computerworld: Pushing iPhone to the EDGE a smart move by Apple Computerworld: Pushing iPhone to the EDGE a smart move by Apple
 Mac Central 02/26/08 11 PM 
Sort files into date-labeled subfolders using Perl Sort files into date-labeled subfolders using Perl
 MacOsxHints 02/25/08 04 PM 
EU: guarded reaction to Microsoft open-source move EU: guarded reaction to Microsoft open-source move
 Macworld UK 02/22/08 10 AM 

Search

Mac Zicos
Wed December 3, 08:32 AM
you   {key13}