How can I create a custom behavior for a URL scheme? 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"
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:

&lt;key&gt;CFBundleURLTypes&lt;/key&gt;
&lt;array&gt;
  &lt;dict&gt;
    &lt;key&gt;CFBundleURLName&lt;/key&gt;
    &lt;string&gt;Magnet&lt;/string&gt;
    &lt;key&gt;CFBundleURLSchemes&lt;/key&gt;
    &lt;array&gt;
      &lt;string&gt;magnet&lt;/string&gt;
    &lt;/array&gt;
  &lt;/dict&gt;
&lt;/array&gt;