Here is the code:
Sublime plugin:
File 1: open_in_default_program.py:
# https://github.com/SublimeTextIssues/Core/issues/2368
import webbrowser
import sublime_plugin
class OpenInDefaultProgramCommand(sublime_plugin.TextCommand):
def run(self, edit):
if self.view.file_name():
webbrowser.open_new_tab("file://" + self.view.file_name())
def is_visible(self):
return self.view.file_name() is not None and (
self.view.file_name()[-5:] == ".html" or
self.view.file_name()[-3:] == ".md" or
self.view.file_name()[-4:] == ".ahk")
File 2: Context.sublime-menu:
[
{ "command": "open_in_default_program" },
]
AutoHotkey test file:
Test.ahk:
MsgBox Something
My question:
It works for HTML and Markdown files. It also works for AutoHotkey files - but how? From what I see, it uses browser. AutoHotkey files can't be opened in browser - but actually they are perfectly could be launched with this plugin. Why it works?
Here is another plugin for opening files in default application, but it's much more complex: https://github.com/SublimeText/OpenDefaultApplication/blob/master/OpenDefault.py