2

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.

2

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.
  • I'm close - I created an app from the AppleScript that opens up a new terminal tab. Using RCDefaultApp I set the ssh handler to this app. However, it doesn't then execute ssh $PLACENAME - it just opens the tab. So I have to pass in the params of the ssh:// protocol to the AppleScript, I think. Got any ideas? – mAAdhaTTah Sep 5 '14 at 20:28
  • Can you have another line in your script to the effect of, 'tell application...... to keystroke "echo testing" '? – webmarc Sep 5 '14 at 20:33
  • I can, but how do I get the url from the ssh:// protocol? – mAAdhaTTah Sep 5 '14 at 20:42
  • I'm pretty sure that it's avail in the argv for whatever shell you're using; so if you're using bash, try using "echo $@" (before the osascript) to see what it looks like. – webmarc Sep 5 '14 at 20:50
  • Oh, I just dropped it directly into an AppleScript app, rather than using shell. Does AppleScript have access to it somewhere? – mAAdhaTTah Sep 5 '14 at 20:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .