2011-07-03

OS X Right Click Menu Additions

I'm sure this is documented somewhere, but I didn't find it while looking. If you use the Automator to create a service that receives files or folders in any application, it will get added to the right click menu. Now I can right click documents and choose to edit them with Vim.

I noticed this while trying to add a hotkey to the service. The hotkey didn't work, but then I noticed my edit option in the menu, so that's almost as good.


So here's how I created a right-click option for Edit with Vim under Snow Leopard:

  • Launch Automator

  • Choose The Service Template

  • Change "Service receives selected" pulldown option from "text" to "files or folders."

  • Drag "Run Shell Script" from the library into the current workflow

  • Change the "Pass input" pulldown from "to stdin" to "as arguments"

  • Delete the text from the edit box and enter the following:


  • Save it as something concise, but descriptive, like: Edit with single Vim



This time I embedded everything for the command in the shell script of the service because I'll only ever need to call this from the gui.


Edit: Update: OS X Lion treats Applications like services. If you create an Application with the Automator, it will likewise show up in your services menu.

2 comments:

Anonymous said...

Thanks so much! I have "Edit with Vim" bound to Shift+Cmd+V. Makes using Vim far easier! Two adjustments I made:

Terminal > Preferences > Settings Tab > Default Profile > Shell Tab > When the shell exits: Close if shell exited cleanly

Then in the automator script, line 4, change it to this:

do script "$@; exit"

You can now close the terminal window with :q

stephen said...

> Terminal > Preferences > Settings Tab > Default Profile > Shell Tab > When the shell exits: Close if shell exited cleanly

D'oh! I didn't even think to look for such an option.