I’m in the middle of creating a custom Main.sublime-menu
file to add some entries for quickly getting the Unofficial docs and some of the parts of it I use most often and I’ve run into something weird here on my Linux machine regarding sublime opening links for me in that it’s not picking the correct browser.
I have Firefox and Chrome both installed, but Chrome is set to be the default browser.
As such, this opens the URL in chrome:
tmartin:dart:~> xdg-open "http://www.sublimetext.com/docs/3/api_reference.html"
Also, this code (executed from the Sublime console directly) opens the link in Chrome:
import webbrowser
webbrowser.open_new_tab ("http://www.sublimetext.com/docs/3/api_reference.html")
However, this code (also executed from the Sublime console directly) opens the link in Firefox instead:
window.run_command ("open_url", {"url": "http://www.sublimetext.com/docs/3/api_reference.html"})
I would have guessed that under the hood Sublime would be using the webbrowser
module here, but I seems to act as if its not. It also doesn’t seem to respect the BROWSER
environment variable, which is also set to point to Chrome.
I dropped this simple plugin and it fixes the problem, but I’m not sure why it’s necessary.
import sublime, sublime_plugin, webbrowser
class OpenUrlCommand(sublime_plugin.WindowCommand):
def run(self, url):
webbrowser.open_new_tab (url)
Is this a bug in sublime or am I just being an idiot here?