Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.6: Use a Service to toggle trash can off and on System 10.6
Snow Leopard only hintThis hint enables you to turn off (and back on) moving files to Trash when deleting files, thus deleting them immediately when the trash is off.

This hint takes advantage of the fact that if the .Trashes folder in a user's home folder is not accessible, Mac OS X ignores it and displays an immediate file deletion warning like the one seen at right.

Create a service in Automator that (via the top two drop-down menus) takes no input and is available in any application. Add a single Run AppleScript action that has following contents:
on run {input, parameters}
  do shell script "chown root ~/.Trash" with administrator privileges
  do shell script "killall Finder"
  return input
end run
Save the service as Bypass Trash. Create another service with the same properties and one AppleScript action, with the following contents:
on run {input, parameters}
  do shell script "sudo chown myusername ~/.Trash" with administrator privileges	
  return input
end run
Replace myusername with your short user name as defined in the Accounts System Preferences panel. Save this one as Enable Trash.

By running the Service in any application (Finder included), you can turn off (and back on) the Trash seamlessly. (Here's what it looks like in action.) Do note that when turning off the Trash, Finder must restart so as to take notice of the folder ownership change.

[robg adds: I haven't tested this one.]
    •    
  • Currently 2.06 / 5
  You rated: 2 / 5 (16 votes cast)
 
[7,085 views]  

10.6: Use a Service to toggle trash can off and on | 6 comments | Create New Account
Click here to return to the '10.6: Use a Service to toggle trash can off and on' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.6: Use a Service to toggle trash can off and on
Authored by: DCJ001 on Feb 09, '10 09:35:58AM

In my experience, if files are being deleted, with the pop up warning being given, instead of being sent to the trash, force quitting (restarting) the Finder resets the issue and files are once again sent to the trash.



[ Reply to This | # ]
Don't kill finder!
Authored by: GaelicWizard on Feb 09, '10 09:46:43AM
I'd advise against killing finder so violently. Killall is a violent command. I'd suggest replacing the do shell script "killall Finder" line with
tell application "Finder" to quit
launch application "Finder"
(two lines).

[ Reply to This | # ]
Don't kill finder!
Authored by: GaelicWizard on Feb 09, '10 09:57:08AM
Here's a rewrite to remove the requirement to enter one's admin password when running this script.
on run {input, parameters}
  do shell script "chmod a-rwx ~/.Trash"
  tell application "Finder" to quit
  launch application "Finder"
  return input
end run
the do shell script… line in the second script would need to be changed to do shell script "chmod u+rwx ~/.Trash".

[ Reply to This | # ]
10.6: Use a Service to toggle trash can off and on
Authored by: solitario on Feb 11, '10 10:20:55AM
Instead of creating a Service to toggle the trash can off or on you could create a service to remove the files directly instead:
  • Set the service to accept files or directories in Finder.
  • Add the action to run a shell script with the input as arguments.
  • And create the shell script as following:
    for f in "$@"
    do
    	rm -rf "$f"
    done
    


[ Reply to This | # ]
rather than futzing with .Trash ...
Authored by: bloodnok on Feb 14, '10 06:11:15PM

... just use the rm command from Terminal. Way faster, doesn't care if the file is open in some app (in actual fact, all unix systems unlink an open file but don't actually free its disk space or inode until the application in question closes it - it just becomes an invisible file), & absolutely no way to recover from accidental deletion. what's not to like?



[ Reply to This | # ]
CAUTION ON THIS TOPIC AND INFO
Authored by: GadgetTO on Apr 03, '10 08:52:05PM

Hi - I have to warn people that the information on this thread (while well intended) is not precise enough warrant putting the code into Automator/appelscript or terminal.

I just spent 3 hours repairing things. I found the solution to my final problem in one line on another site. It worked for me to get my trash back to normal because I kept getting a message saying that what I was deleting was not reversible (no trash access). The 'Enable Trash' info presented does not work!. Again, this worked for ME.

1. enter this into Terminal exactly as I have here:

sudo rm -r ~/.Trash

2. if it works for you, you will be asked for your system password. Enter it.
3. Force quite, Finder. It will restart automatically.
4. You should be able to then command-delete as normal (sending items to trash).

thanks



[ Reply to This | # ]