How to put a custom launcher in the Dock (Mavericks)

Solution 1:

You can write it as a shell script within the Run Shell Script action in Automator:

Automator

Save it with the type Application (instead of Workflow) and place it in your Applications folder. It can now be placed in the Dock.

Solution 2:

Automator and AppleScript are the best ways at creating custom scripts/apps that perform commands as you described. Each have their pros and cons. For most tasks I prefer to write AppleScripts, probably because I'm a programmer myself and because they are easy to access and edit.

To write AppleScripts, you can use the OS X provided program called "AppleScript Editor." AppleScript editor allows you to write your AppleScripts and save them as an actual AppleScript with a file extension of .scpt or as an Application (.app) which can be run from anywhere.

If you save your AppleScript in the AppleScript format (.scpt), and with the help of a application called FastScripts (also available in the Mac App Store), all your personal scripts and system scripts can be made easily accessible in the menubar. And Fast Scripts provides the extra benefit of allowing you to assign keyboard shortcuts to them. You can do the same with Automator workflows, I just find it's easier to do with AppleScripts and FastScripts.

Here is a sample AppleScript I created that I have previously shared on the boards that toggles the visibility of hidden files in OS X. This is one of my more basic scripts which is I why I am showing it as an example of how simple it is to write an AppleScript. With the help of FastScripts, I set a keyboard shortcut of ^ + + + . to activate this script.

tell application "System Events"

    set hiddenFilesDisplayStatus to do shell script "defaults read com.apple.finder AppleShowAllFiles"
    set hiddenFilesNewDisplayStatus to "NO"

    if hiddenFilesDisplayStatus is "NO" then
        set hiddenFilesNewDisplayStatus to "YES"
    end if

    do shell script "defaults write com.apple.finder AppleShowAllFiles " & hiddenFilesNewDisplayStatus
    do shell script "killall Finder"

end tell

I have a variety of other AppleScripts that perform various tasks, so if I were you, look at AppleScripts first, then look at using Automator. There are many resources out there for helping you create AppleScripts, and you'll find that there are many others that have already written AppleScripts that may already do what you are looking for.

To answer your specific use case

Try creating an AppleScript with the following command, notice the fully qualified path to xterm. On my machine it was different than yours. It's important to note that I have XQuartz installed on my machine since Mavericks does not come shipped with X11 any longer.

do shell script "/usr/X11/bin/xterm -fg orange -bg black -e ssh me@myserver"

I tried the above command, pointed to my server and it worked fine. What would be really cool if you got this working with this AppleScript is that you could even set up the AppleScript to ask for input for the username and server you with to connect to, and it'll set that in the shell script command for you and if nothing is provided, you could have it default to a particular username/server. :)

FYI, I figured out the pathing issue to xterm using this SO article: https://stackoverflow.com/questions/11206872/open-xterm-telnet-connection-mac-os-x