Change default ssh:// behavior

sshtabsterminal

Currently, the protocol handler ssh:// opens the link in a new Terminal.app window. I'd like to default it so it opens it in a new tab instead. How can I change this behavior?

Backstory: I use Alfred and a workflow to open my ssh connections. The workflow uses the ssh:// handler to open the window.

Best Answer

If you don't mind using some command-line tomfoolery:

osascript -e 'tell application "Terminal" to activate' -e 'tell application "System Events" to tell process "Terminal" to keystroke "t" using command down'

This is from a stack overflow question on a similar topic.

If you want you can even create a new URL handler (or replace the ssh:// one) with a shell script as described at another stack overflow question.

EDIT1: you can get command line args from osascript by using something like the following (taken from the osascript man page):

a.scpt:
on run argv
    return "hello, " & item 1 of argv & "."
end run


% osascript a.scpt world
hello, world.