0

I would like a specific URL scheme, magnet:, to run a command in Terminal.

For example:

magnet:?xt=urn:bKKH

Would execute:

myCommand "magnet:?xt=urn:bKKH"
  • 2
    There is no way typing e.g. magnet:?xt=urn:bKKH in a Terminal is gong to do anything other then -bash: magnet:?xt=urn:bKKH: command not found unless you actually have an executable named e.g. magnet:?xt=urn:bKKH. That said, I see you have an "automator" tag set so if Automator is involved, or not, I think you need to clarify what you're asking for and in what context. – user3439894 Aug 18 '15 at 16:39
  • I think there was a misunderstanding. I won't type magnet in my terminal, I will click on a magnet link on my browser. – nute Aug 19 '15 at 6:45
  • This Super User post might be helpful. – aaplmath Aug 21 '15 at 20:11
1

I found my answer using AppleScript:

https://support.shotgunsoftware.com/entries/127152-Launching-External-Applications-using-Custom-Protocols-under-OSX

  • Create an AppleScript that uses on open location this_URL
  • Save as Application
  • Edit the Info.plist of the Application with:

    <key>CFBundleURLTypes</key>
    <array>
      <dict>
        <key>CFBundleURLName</key>
        <string>Magnet</string>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>magnet</string>
        </array>
      </dict>
    </array>
    

You must log in to answer this question.

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