Skip to content

Instantly share code, notes, and snippets.

@georgebrock
Last active October 9, 2025 11:00
Show Gist options
  • Save georgebrock/9ab3d83bf160b7c1c2b0 to your computer and use it in GitHub Desktop.
Save georgebrock/9ab3d83bf160b7c1c2b0 to your computer and use it in GitHub Desktop.

Revisions

  1. georgebrock revised this gist Feb 7, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Info.plist
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    <!-- ... -->

    <!-- Add this section: -->
    <key>CFBundleURLTypes</key>
    <key>CFBundleURLTypes</key>
    <array>
    <dict>
    <key>CFBundleURLName</key>
  2. georgebrock renamed this gist Feb 7, 2016. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. georgebrock created this gist Feb 7, 2016.
    23 changes: 23 additions & 0 deletions Info.plist
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <!-- ... -->

    <!-- Add this section: -->
    <key>CFBundleURLTypes</key>
    <array>
    <dict>
    <key>CFBundleURLName</key>
    <string>HTTP URL</string>
    <key>CFBundleURLSchemes</key>
    <array>
    <string>http</string>
    <string>https</string>
    </array>
    </dict>
    </array>
    <!-- End of what needs adding -->

    </dict>
    </plist>
    3 changes: 3 additions & 0 deletions example.applescript
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    on open location this_URL
    display alert this_URL
    end open location
    10 changes: 10 additions & 0 deletions instructions.markdown
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    Follow these instructions to create an AppleScript App that can be used to open URLs, e.g. from [Choosy](https://www.choosyosx.com).

    1. Open Script Editor (in `/Applications/Utilities`).
    2. Write a script with an `on open location` handler (see `example.applescript`).
    3. Save the script as an application (select "Application" from the file format dropdown in the save dialog in Script Editor).
    4. Edit the application's `Info.plist` file to add a `CFBundleURLTypes` section, indicating it can handle HTTP URLs (see `Info.plist`). If the app is at `~/Applications/MyApp.app` then the `Info.plist` will be at `~/Applications/MyApp.app/Contents/Info.plist`.
    5. Test your application from the command line using `open -a ~/Applications/MyApp.app http://www.example.com`
    6. Update the AppleScript to do something useful with the URL (the [`do shell script` command](http://www.cyberciti.biz/faq/mac-osx-applescript-run-shell-script/) might be useful if you want to avoid writing more AppleScript).
    7. ?
    8. Profit.