Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I use a bash script as a Service in OS X without having to set it up trough automator? I'd basically like to write a bash script, save it in ~/Library/Services and then just have it show up in the services menu. Thoughts?

share|improve this question
    
The mac tag is for questions about Mac hardware. While the osx tag is for software. Choose one or the other. –  Wuffers Apr 5 '11 at 0:32

3 Answers 3

up vote 3 down vote accepted

ThisService is a bit more streamlined than Automator:

thisservice


The built-in script menu can also be used to run shell scripts:

script menu shell scripts

It can be enabled from AppleScript Utility — Preferences — Show Script menu in menu bar. It includes files in ~/Library/Scripts/ and optionally /Library/Scripts/. You can't assign shortcuts though — that's the main reason to use FastScripts instead.


Some applictions for just assigning shortcuts: osx - Bind a key to a commandline command in Mac OS X? - Super User.

share|improve this answer
    
Do you know whether it's actually different from an Automator service (e.g. performing better), or just a different implementation of the same idea/different GUI? Can it be automated or controlled from command line? –  Daniel Beck Mar 31 '11 at 18:15

You should consider trying FastScripts. It's like OS X's scripts menu done right, including keyboard shortcuts for easy access.

share|improve this answer

I don't know of a way to do that directly. Aside from Automator, you can also use XCode to build an AppleScript wrapper for your script that will work as a Service.

Using the script directly is more problematic. My understanding is that it needs to be an app bundle, and then it needs specific entries in its Info.plist telling the system what service it offers. The former can be done with Platypus; for the latter, use the Property List Editor in XCode (or plutil and an XML editor if you hate yourself like playing with XML directly) to craft an NSServices key.

This leaves the rather big question of how to invoke it; the Objective-C message created from NSServices key NSMessage isn't going to be understood directly by a shell, and it looks like Platypus doesn't have a way to receive it either. I suspect that means writing a custom wrapper in Objective-C.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.