Add a “Permanently Delete” Option to Your Mac

Jul 12, 2013

Anyone who grew up on PCs will be familiar with the old Shift+Delete trick—that combination of keystrokes that immediately and permanently nukes a file. For many, it’s a surprise to find that OS X doesn’t offer that functionality without cumbersome Terminal commands or third-party apps. Instead, you must first move a file to Trash, and then “empty” the Trash. Only then is a file truly gone—along with everything else in your Trash.

But what if you only want to delete a particular file at a given time? With Automator, you can add the functionality to your context menus (“right-click” menus) using the Services workflow.

You can create an Automator service or application to facilitate executing the rm shell commando, which will permanently delete files or folders and skip the trash.

To begin, start by creating a new Service in the Automator app.

Select “files or folders” as input; you may also want to limit the availability of this service to the Finder app.

Optional—but highly recommended to prevent accidental deletion—is the addition of an Ask for Confirmation step to the workflow. Drag it into your workflow from the column at left, then customize the message and the Cancel and OK buttons to your liking.

Finally, add the Run Shell Script step to the workflow, again dragging from left. Make sure to pass input “as arguments”. Then you can put in the following script:

for f in “$@”
rm -rf “$f”

To complete the process with a bit of audio confirmation, add the OS X “emptied trash” sound by including the following command at the end of the shell script:

afplay “/System/Library/Components/
SystemSounds/finder/empty trash.aif”

Save your service, and it should be ready to use in Finder from the Services menu in the menu bar. You can also configure a keyboard shortcut to your service in the Keyboard preference pane of System Preferences.

Source/Screenshots :