├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── atom-handler.app └── Contents │ ├── Info.plist │ ├── MacOS │ └── applet │ ├── PkgInfo │ └── Resources │ ├── Scripts │ └── main.scpt │ ├── applet.icns │ ├── applet.rsrc │ └── description.rtfd │ └── TXT.rtf └── src └── atom-handler.applescript /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | /.config 4 | /coverage/ 5 | /InstalledFiles 6 | /pkg/ 7 | /spec/reports/ 8 | /test/tmp/ 9 | /test/version_tmp/ 10 | /tmp/ 11 | 12 | ## Specific to RubyMotion: 13 | .dat* 14 | .repl_history 15 | build/ 16 | 17 | ## Documentation cache and generated files: 18 | /.yardoc/ 19 | /_yardoc/ 20 | /doc/ 21 | /rdoc/ 22 | 23 | ## Environment normalisation: 24 | /.bundle/ 25 | /lib/bundler/man/ 26 | 27 | # for a library or gem, you might want to ignore these files since the code is 28 | # intended to run in multiple environments; otherwise, check them in: 29 | # Gemfile.lock 30 | # .ruby-version 31 | # .ruby-gemset 32 | 33 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this: 34 | .rvmrc 35 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 1.1.3 2 | 3 | Handle file paths with escaped at-signs (@), e.g. `atm://open?url=file:///users/me/rubies/ruby-2.3.4%40myproject/gems/library/source.rb&line=433` (`atm://open?url=file:///users/me/rubies/ruby-2.3.4@myproject/gems/library/source.rb&line=433`) 4 | 5 | ## 1.1.2 6 | 7 | Handle file paths with spaces, e.g. `atm://open?url=file:///users/me/Google Drive/project/file.txt` 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, Andrew Ogzewalla 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the {organization} nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # _Update 12/2017_ 2 | 3 | After many years of waiting Atom finally supports URI handling. If your Atom is up-to-date then you no longer need this package! 4 | 5 | The [open](https://atom.io/packages/open) package now provides support and instructions for opening local files in Atom via URL. 6 | 7 | # Atom Handler 8 | 9 | A handler to open atm:// URLs in Atom editor on OSX. Inspired by [subl](https://github.com/dhoulb/subl). 10 | 11 | Atom Handler registers itself to handler links with the `atm://` protocol, similar to the protocol TextMate handles (txmt://) or the which can be used for Sublime Text (subl:// or sublime://). The protocol can then be used to open files in your Atom editor. Read on to learn how to use Atom Handler. 12 | 13 | Note: We would have liked to have used `atom://` as a protocol, but that is already taken and used for other purposes by Atom itself. 14 | 15 | ## Prerequisites 16 | 17 | - Install Atom Shell Commands. Within Atom select from the menu: `Atom > Install Shell Commands` 18 | 19 | ## Installation 20 | 21 | - Download the latest release [(atom-handler.app.zip)](https://github.com/WizardOfOgz/atom-handler/releases/download/v1.1.3/atom-handler.app.zip) and unzip it. 22 | - Move atom-handler.app into your `/Applications` directory. 23 | - Open the application which will register the handler and exit immediately. 24 | 25 | Opening the application in the last step may be prevented by OS security. If that happens go to `System Preferences > Security & Privacy`. You should see a message about "atom-txmt-url-handler" being blocked. Click the button which says "Open Anyway". 26 | 27 | Note: Nothing appears on the screen when you open the application. Also, opening the application does not have any effect after the first time, opening it multiple times will do no harm. 28 | 29 | ### Testing the Installation 30 | 31 | You can quickly test the installation from the command line. These commands should create a file and open it in Atom: 32 | 33 | ``` 34 | echo "Hello, world" >> /tmp/test.txt 35 | open "atm://open?url=file:///tmp/test.txt" 36 | ``` 37 | 38 | ## Usage 39 | 40 | Atom Handler will handle URLs which match the [TextMate URL scheme](http://blog.macromates.com/2007/the-textmate-url-scheme/) and take the following format: 41 | 42 | `atm://open?url=file://[&line=[&column=]]` 43 | 44 | Opening a URL with this format will open the given file in the Atom editor and place the cursor at the beginning of the line number (if given). Note that the column option does not seem to be supported by the Atom command line utility. If a column is given then Atom simply ignores it. The option is supported for compatibility with TextMate and Sublime Text URLs. 45 | 46 | ### Examples: 47 | - `atm://open?url=file:///path/to/other` 48 | - `atm://open?url=file:///path/to/other&line=42` 49 | - `atm://open?url=file:///path/to/file&line=42&column=7` 50 | - `atm://open?url=file://%2Fpath%2Fto%2Fother # URL-encoded slashes (/)` 51 | 52 | These URLs may be opened from a browser or from the command line using the system `open` command. See the [Integrations](#Integrations) section below for use with popular platforms and frameworks. 53 | 54 | ## URL Encoding 55 | 56 | Note that The file path may contain the following URL-encoded values. 57 | 58 | |name|character|URL encoding| 59 | |---|---|---| 60 | |slash|`/`|`%2F`| 61 | |space|` `|`%20` OR `+`| 62 | |plus|`+`|`%2B`| 63 | |at|`@`|`%40`| 64 | 65 | Plus-signs are legal characters in file names and _must_ be escaped as `%2B` since an unescaped `+` will be transformed into a space character. We highly discourage using plus-signs in file names since support for it varies across systems. 66 | 67 | Spaces in file names must likewise be escaped. These are also discouraged since many scripts and applications do not handle them properly. 68 | 69 | ## Known Limitations 70 | 71 | Currently this application relies on the `atom` CLI utility being accessible at `/usr/local/bin/atom` in order to open the files. If there is a better way of finding the CLI utility, please let me know or open a pull request. 72 | 73 | ## Integrations 74 | 75 | ### BetterErrors (Ruby on Rails) 76 | 77 | Install [Better Errors](https://github.com/charliesome/better_errors) in your Rails application and add the following code to an initializer (or any other location where it will be executed when your application is loaded.) 78 | 79 | ```ruby 80 | if defined? BetterErrors 81 | BetterErrors.editor = "atm://open?url=file://%{file}&line=%{line}" 82 | end 83 | ``` 84 | 85 | ### PHP Xdebug 86 | 87 | Install [Xdebug](http://xdebug.org) for PHP, add the following to your php.ini, and restart your webserver. 88 | 89 | ``` 90 | xdebug.file_link_format="atm://open?url=file://%f&line=%l" 91 | ``` 92 | 93 | ## License 94 | 95 | Atom Handler is released under the [BSD 3-Clause license](https://github.com/WizardOfOgz/atom-handler/blob/master/LICENSE). 96 | -------------------------------------------------------------------------------- /atom-handler.app/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleAllowMixedLocalizations 6 | 7 | CFBundleDevelopmentRegion 8 | English 9 | CFBundleExecutable 10 | applet 11 | CFBundleIconFile 12 | applet 13 | CFBundleIdentifier 14 | com.wizardofogz.atom-handler 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | atom-handler 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 1.1.3 23 | CFBundleSignature 24 | aplt 25 | CFBundleURLTypes 26 | 27 | 28 | CFBundleURLName 29 | Atom Handler 30 | CFBundleURLSchemes 31 | 32 | atm 33 | 34 | 35 | 36 | LSMinimumSystemVersionByArchitecture 37 | 38 | x86_64 39 | 10.6 40 | 41 | LSRequiresCarbon 42 | 43 | LSUIElement 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /atom-handler.app/Contents/MacOS/applet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WizardOfOgz/atom-handler/ec1d4c9bb52808ba4f739930781e76a5cb6dabea/atom-handler.app/Contents/MacOS/applet -------------------------------------------------------------------------------- /atom-handler.app/Contents/PkgInfo: -------------------------------------------------------------------------------- 1 | APPLaplt -------------------------------------------------------------------------------- /atom-handler.app/Contents/Resources/Scripts/main.scpt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WizardOfOgz/atom-handler/ec1d4c9bb52808ba4f739930781e76a5cb6dabea/atom-handler.app/Contents/Resources/Scripts/main.scpt -------------------------------------------------------------------------------- /atom-handler.app/Contents/Resources/applet.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WizardOfOgz/atom-handler/ec1d4c9bb52808ba4f739930781e76a5cb6dabea/atom-handler.app/Contents/Resources/applet.icns -------------------------------------------------------------------------------- /atom-handler.app/Contents/Resources/applet.rsrc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WizardOfOgz/atom-handler/ec1d4c9bb52808ba4f739930781e76a5cb6dabea/atom-handler.app/Contents/Resources/applet.rsrc -------------------------------------------------------------------------------- /atom-handler.app/Contents/Resources/description.rtfd/TXT.rtf: -------------------------------------------------------------------------------- 1 | {\rtf1\ansi\ansicpg1252\cocoartf1504\cocoasubrtf810 2 | {\fonttbl} 3 | {\colortbl;\red255\green255\blue255;} 4 | {\*\expandedcolortbl;;} 5 | } -------------------------------------------------------------------------------- /src/atom-handler.applescript: -------------------------------------------------------------------------------- 1 | on open location atomURL 2 | -- URL should take the form of "atm://open?url=file://[&line=[&column=]], e.g. atm://open?url=file://%2Fpath%2Fto%2Ffile&line=10&column=4 3 | -- Note that file path should be URL encoded. 4 | -- Slashes (/) should be encoded as %2F. 5 | -- Spaces should be encoded as %20, NOT as a plus sign (+) because a plus sign is a legal character on filenames! 6 | set idx to the offset of "url=file://" in atomURL 7 | set file_path to text from (idx + 11) to -1 of atomURL -- just get the file path and line 8 | -- 's/^[^&]*/'\"'\"'&'\"'\"'/' -- Surround the file name in strong (single) quotes, e.g. %2Fpath%2Fto%2Ffile&line=3 => '%2Fpath%2Fto%2Ffile'&line=3 9 | -- s/\\\\%2F/\\\\//g -- Unencode escaped slashes (/), e.g. '%2Fpath%2Fto%2Ffile' => '/path/to/file' 10 | -- sed -E 's/%20|\\+/\\ /g' -- Unencode escaped spaces, e.g. 'user/Google%20Drive/my+project/file' => 'user/Google Drive/my project/file' 11 | -- s/%40/@/g -- Unencode escaped @, e.g. 'user/Google%20Drive/my+project@2.3.4/file' => 'user/Google Drive/my project@2.3.4/file' 12 | -- sed s/%2B/+/g -- Unencode escaped plus-signs, e.g. 'project/one%2Btwo/file' => 'project/one+two/file' 13 | -- s/\\&line=/:/ | sed s/\\&column=/:/ -- Change the format of the line and column parameters, e.g. '/path/to/file'&line=3&column=4 => '/path/to/file':3:4 14 | set file_path to do shell script "echo '" & file_path & "' | sed 's/^[^&]*/'\"'\"'&'\"'\"'/' | sed s/\\\\%2F/\\\\//g | sed -E 's/%20|\\+/\\ /g' | sed 's/%40/@/g' | sed s/%2B/+/g | sed s/\\&line=/:/ | sed s/\\&column=/:/" 15 | do shell script "/usr/local/bin/atom " & file_path 16 | end open location 17 | --------------------------------------------------------------------------------