Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Here is how I did it for Safari, change accordingly.

Go to Tools/BuildSystem/NewBuildSystem... Type this in:

    {
        "cmd": ["open", "-a", "Safari", "$file"],
        "selector": "html"
    }
Save it in your sublime/packages/user folder as 'Open in Safari.sublime-build'

That's it.

It should show up in your Tools/BuildSystem and should be selected for all html files. So when you hit Cmd+B it uses that build system to just show the file in Safari.

There are other ways like mapping Cmd+B directly to a python snippet like:

    import sublime, sublime_plugin, webbrowser

    class OpenBrowserCommand(sublime_plugin.TextCommand):
       def run(self,edit):
          url = self.view.file_name()
          webbrowser.open_new(url)
but for me the first option was simpler.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: