3

Possible Duplicate:
Permanently deleting files on Mac OS

What's the Mac keyboard shortcut to rm a file? I know command + delete sends it to trash, but I want to permanently delete it, say with command + fn + delete.

UPDATE: It doesn't look like there is one. So, I want to create a service with Automator and then assign a keyboard shortcut to it from System Preferences.

I can get to Automator -> Service -> Service receives selected files or folders in Finder.app, but how do I write the script that then runs rm -rf #{file/folder name}?

ma11hew28
  • 748

4 Answers4

4

To answer your edit requesting Automator help:

Use the Run Shell Script action, Pass input as arguments and the following script:

for f in "$@"
do
    rm -rf "$f"
done

You can assign a keyboard shortcut via Application Menu, Services, Services Preferences. It's a bit difficult to assign backspace/"delete" to a keyboard shortcut (see comments on this answer) though.

You can alternatively create an application in Automator, and add a reference to the Finder toolbar (applications can be dragged there).


Assigning a keyboard shortcut using delete (backspace) or forward delete:

  1. Define a simple keyboard shortcut for the service without delete (e.g. Cmd-Ctrl-Opt-G) using System Preferences. Quit System Preferences.
  2. Open ~/Library/Preferences/pbs.plist using Property List Editor and copy the key for the service. It's within NSServicesStatus and looks something like (null) - Service Name - runWorkflowAsService. Quit Property List Editor.
  3. Open Terminal and enter the following command (use the line you copied earlier between the quotes and double-quotes):

    defaults write pbs NSServicesStatus -dict-add '"(null) - Service Name - runWorkflowAsService"' '{ "key_equivalent" = "@\U0008"; }'

  4. Open Application Menu » Services » Service Preferences, and toggle your service.

  5. Enjoy your new key combination.

In the command line, @ is Cmd, ^ is Ctrl, $ is Shift, and ~ is Option. Mix and match these modifiers to your preferences. \U0008 is delete (backspace), \U007F is forward delete.

alt text

Daniel Beck
  • 111,893
1

See this MacGeekery post.

Matt Ball
  • 3,912
1

I'm not sure what the keyboard shortcut is or even if it exists but you can run an applescript that will permanently delete files. Here's a link with instructions http://macphobia.com/deleting-an-item-windows-and-mac.macphobia

0
set txt to ""
tell application "Finder"
    repeat with f in (get selection)
        set txt to txt & quoted form of POSIX path of (f as text) & " "
    end repeat
end tell
set cmd to "rm -rf " & txt
display dialog cmd & "?"
do shell script cmd

You can use FastScripts (or for example Keyboard Maestro) to assign a shortcut that's only available in Finder.

Lri
  • 42,502
  • 8
  • 126
  • 159