Atom:// protocol handler


#1

I’d like to be able to have atom open urls like atom:///Users/me/myfile.txt.

From this PR it looks like there might be support for this, but currently when I try that I get an error like the following:

uncaughtException
ReferenceError: atom is not defined
    at Function.module.exports.Package.isBundledPackagePath (/Applications/Atom.app/Contents/Resources/app/src/package.js:42:11)
    at Function.module.exports.Package.loadMetadata (/Applications/Atom.app/Contents/Resources/app/src/package.js:59:16)
    at PackageManager.module.exports.PackageManager.getAvailablePackageMetadata (/Applications/Atom.app/Contents/Resources/app/src/package-manager.js:233:128)
    at AtomApplication.module.exports.AtomApplication.openUrl (/Applications/Atom.app/Contents/Resources/app/src/browser/atom-application.js:652:35)
    at EventEmitter.<anonymous> (/Applications/Atom.app/Contents/Resources/app/src/browser/atom-application.js:362:24)
    at EventEmitter.emit (events.js:110:17)

Is this a bug? Unsupported? Am I doing something wrong?


#2

You can just use file:// URLs for this. file:///Users/me/myfile.txt should work fine.


#3

I should clarify that I’m wanting to open files in atom from the browser, so file:// isn’t going to work.


#4

Ah, in that case it is not possible. The atom:// protocol only handles files in ~/.atom so that packages can find their resources no matter where they’re installed. It’s also only really for resources referenced in HTML/CSS.

It looks like protocols don’t work when actually opening files in Atom, they get mangled. e.g. opening atom://test in your home directory results in Atom thinking you want a file named ~/atom:/test.

I assume you’re looking for something like sublime text’s subl://open URLs - you should open an issue for it as I’m sure many people would find it useful.


#5

I ran into a problem with protocol handling recently. My web-browser handles http and https protocols. I use these protocols when opening a web page from my command-toolbar (being used for favorite urls). However I can’t use this from a command line like atom http://apple.com because atom chokes when it doesn’t have a folder. It should just open it like normal with the plain atom and an untitled tab and of course my web page.

Maybe I’ll submit an issue on atom/atom.

Edit: See https://github.com/atom/atom/issues/4270


#6

Opened a feature request here: https://github.com/atom/atom/issues/4290


#7

Here’s the issue tracking this very, very missed feature!


#8

Sorry to bump an old thread, but since this is still an open issue I want to steer anyone landing here to another thread about the topic: URL Helper à la "atom://"

As discussed in that other thread, I have an app which handles atm:// protocol requests (atom:// is already taken by Atom itself) and can be found here: atom-handler. I hope that can help some others until Atom can open files by atom:// URL (or some other means).


#9

Note that there’s also a Linux based uurl handler here: https://github.com/eclemens/atom-url-handler