Can a SSH session be wrapped to appear as a distinct App

applicationsssh

Fluid can create a .app wrapper around a webkit instance to turn any web page into an OSX Application. This script can do a less thorough job with Chrome. Is there anything that can do this for a ssh session, possibly through a Terminal or iTerm2 profile, or a standalone SSH client?

To elaborate:

I open Safari, then open a second Safari window for a particular website. Now cmd+tab and force quit and mission control and the dock and many other OSX features treat those two windows as part of the same app.

Instead, after opening Safari, I can open my created-with-Fluid custom .app for the particular website. This gives me all the OS-native features of having two separate apps running.

Analogously, in Terminal or iTerm2 or a standalone SSH client (e.g. CyberDuck or SecureCRT) I can open a second window with a particular profile loaded that will ssh to a certain server. That window will, again, be treated by the OS as part of the single running app.

I am hoping for something like Fluid that will create a .app wrapper around any method of opening an SSH session to a particular server, which will then stand alone from any other SSHing I'm doing in my normal usage.

Best Answer

The only way to run multiple, separate instances of Terminal is by launching them with the command line open -n -a "Terminal" -- understand that this isn't a great way to run things that aren't meant to be run like this. There are shared preferences and plist files being used by these instances so you may run in to trouble.

The reason Fluid works so well is each app is a separate WebKit browser instance, with a unique preference namespace, and without the normal browser window decorations. It's a heavy hack to say the least.

You can script Terminal with AppleScript and then save the AppleScript as an application. This script forces a new instance of Terminal to the foreground and then runs an ssh command in it:

do shell script "open -n -a Terminal"
tell application "Terminal"
   set currentTab to do script ("ssh user@server;")
   # Additional commands can be sent using...
   # delay 6
   # do script ("do something remote") in currentTab
end tell

Enter that in to the AppleScript Editor, customize it as suits your needs, and then select File > Save... and where it says Type: in the Save dialog select Application.

This will create an unsigned .app file you can distribute as an Application to start ssh sessions. If you have a developer certificate and want to code sign the .app so users don't get a warning about running untrusted code use the File > Export... menu option, select Application for the Type and make sure the Code Sign: option in the dialog pointing to a developer certificate instead of Don't Code Sign.

It is preferred to code sign the app if you're going to give the app to other users.

If you run that, you'll get entirely new Terminals started, independent of each other, that you can Cmd-Q quit without quitting the other instances. Replace Terminal in the script with iTerm if you prefer it for your command line work.