Open in external app using "Open file" and links


I would like to be able to use “Open file” from the menu to open a file with an external application, as required (e.g., open a .pdf file with the default PDF reader). Similarly, if I click on a link to a path (e.g., …/pru.pdf) I would like that file to open with the PDF reader rather than as another (text) file in Atom. I have used the package, which works great, but it seems to work only if the file is selected from the tree view. However, it would be really very useful if the feature of external opening is also activated when clicking on a link and when opening a file from the menu (these two options lead to the file being opened as a text file directly in Atom).

Any way to do that? Could the package be adapted easily to support this? Or is there any other alternative? Thank you very much.


You can easily do this in your file using Node’s child_process module:

{spawn} = require 'child_process'

atom.contextMenu.add {
  ".tree-view": [{
    label: "Open file in default program"
    command: "custom:open-in-default"

atom.commands.add ".tree-view", "custom:open-in-default", (evt) ->
  spawn"data-path").value, {shell: true}

Open git bash from Atom

Thank you very much for the nice code !

However, I think that I did not explain my problem correctly. Opening with the default external program using the tree view already works in my system (thanks to the package I understand that the code proposed is an alternative to using that package (I tried it and it seems to work perfectly also).

However, what I want is that the file is opened in the default application even if I don’t open the file through the tree view. Particularly, when clicking on a link within a text file opened in Atom, such as:


Probably the hyperclick package is at work here.

Any suggestion is welcome, as this would be really very useful.

Thank you.


hyperclick offers an API to provider packages to create clickable text, so I suspect that the important factor is which package is actually creating the link. What providers do you have installed?


I think it is path-hyperclick (

Thank you.


Here’s the DOM view of a link that’s been highlighted and is clickable with hyperclick and path-hyperclick:

There’s no scope here that identifies it as a link, so the only option for tweaking the behavior of the clickable area is to make a change to the package itself.