How to add shells to the list in Run Shell Script in the Automator

automatorcommand line

If I select the Run Shell Script action in Automator, it has a drop down menu filled with possible shells:

/bin/bash  
/bin/csh  
/bin/ksh  
/bin/sh  
/bin/tcsh  
/bin/zsh  
/usr/bin/perl  
/usr/bin/python  
/usr/bin/ruby  
/Users/iain/Library/Frameworks/zsh/Programs/zsh  

I reckon that some of that list came from /etc/shells, especially as it has tacked on my custom zsh at the end (unless it's read the currently selected shell from somewhere else). I also have an updated Ruby in /opt/rubies/ruby-2.1.2/ which I'd like to use for this shell script action.

Would anyone know how I can add it to the list? I've tried adding it to /etc/shells which didn't work (and seems like a horrible hack). Doing that removed the custom zsh from the list too!

Also, when I first pull in the action my current shell (the custom zsh) is automatically selected. If I try to use the drop down and re-select the custom zsh, it selects /bin/bash instead and removes the custom zsh from the list. If, however, I leave the custom zsh select and I save the workflow and restart automator, the custom zsh is missing and there is no shell selected for the action.

I could use one of the existing shells to call the custom Ruby, but it would obviously be easier to remove a layer of redirection

Any help with this will be much appreciated.

Best Answer

The list of these shells in this action come from this PLIST file --> "/System/Library/Automator/Run Shell Script.action/Contents/Resources/Shells.plist"

Edit this file to add others shells (need administrator's password)

    <key>/Users/iain/Library/Frameworks/zsh/Programs/zsh</key>
<dict>
    <key>args</key>
    <array>
        <string>-c</string>
        <string>%</string>
        <string>-</string>
    </array>
    <key>script</key>
    <array>
        <string>cat</string>
        <string>for f in "$@"&#10;do&#10;&#09;echo "$f"&#10;done</string>
    </array>
</dict>
<key>/opt/rubies/ruby-2.1.2/</key>
<dict>
    <key>args</key>
    <array>
        <string>-e</string>
        <string>%</string>
        <string>--</string>
    </array>
    <key>script</key>
    <array>
        <string>ARGF.each do |f|&#10;&#09;puts f&#10;end</string>
        <string>ARGV.each do |f|&#10;&#09;puts f&#10;end</string>
    </array>
</dict>