Open terminal via Safari

safariterminal

Is it possible to open a terminal window from a Safari webpage?
I have found a way to open a ssh terminal window, but is it possible to only open the terminal window without pre filled commands?

I have tried to search on google but i only find solutions for opening Safari from terminal.

To open terminal with ssh from Safari i put the following link on a webpage:

<a href="ssh://adminuser@10.225.xxx.xxx">ssh</a>

Best Answer

There are three URL types which can open Terminal from Safari:

  1. ssh
  2. telnet
  3. x-man-page

Those informations can be found under CFBundleURLTypes key in: /Applications/Utilities/Terminal.app/Contents/Info.plist

So in order to open Terminal app, you can place link like:

<a href="telnet://">telnet</a>

<a href="ssh://">ssh</a>

<a href="x-man-page://">man page</a>

It does not prefill informations in Terminal for me.


Bonus: This rule can be applied to any application that can open URLs.

Check URL types of the app with:

defaults read /absolute/path/to/Info.plist CFBundleURLTypes

for example:

defaults read /Applications/Utilities/Script\ Editor.app/Contents/Info.plist CFBundleURLTypes

This gives me applescript as URL type, so making link like:

<a href="applescript://">Script Editor</a>

Opens the Script Editor app.