Open joeaddison opened 5 years ago
I had the same problem. Was able to fix it. It seems the problem is caused because my Windows (Windows 10) syntax for opening the browser expects one format and this plugin uses a different format. Specifically, this plugin uses start '<a url>'
, whereas my format uses either start <a url>
(no quotes; quotes of any kind when browser is not specified does not seem to work) or e.g. start chrome "<a url>"
(double quotes around the URL is OK; note that I've updated this - previously I thought double quotes around the browser name worked, but it seems that that was just using the default browser and not respecting the assigned "custom_browser" value in the sublime settings). Basically, quotes generally don't seem to work.
The way I was able to fix it was in open_in_browser.py
, changing these lines:
Line 62 was: status = os.system("start '{url}'".format(url=url))
Line 62 changed to: status = os.system("start {url}".format(url=url))
Line 55 was: status = os.system("start '{browser}' '{url}'".format(browser=browser, url=url))
Line 55 changed to: status = os.system('start {browser} "{url}"'.format(browser=browser, url=url))
I was able to make the change locally (didn't make a pull request...) by following the section "Packed vs. Unpacked" in https://packagecontrol.io/docs/customizing_packages.
Additional notes: Got help with Windows cmd syntax from: https://superuser.com/questions/153245/how-can-i-open-google-chrome-via-command-line-with-a-url-in-incognito-mode/153292
Natlefiyr, is there a way to not show CMD for 1/3 of a second when opening a hyperlink ?
Also i cant figure out how to open a link in custom browser but in incognito/private window, i tried typing "custom_browser": "firefox -private-window", but it doesnt work
@mato200
This seems to hide the Windows CMD / Command Prompt window from displaying briefly before opening the webpage:
Line 55 changed to:
try:
status = 0
subprocess.call('start {browser} "{url}"'.format(browser=browser, url=url), shell=True)
except:
status = 99
(I at first had problems where it didn't seem to recognize the subprocess module, but that seemed to go away - may have had to type import subprocess
in the Sublime command prompt?)
Referenced: https://stackoverflow.com/questions/7006238/how-do-i-hide-the-console-when-i-use-os-system-or-subprocess-call
Ok, so I guess for the "custom_browser" setting you're talking about in the OpenInBrowser.sublime-settings file. So it looks in the start
command-line function like having quotes around the browser doesn't work like I originally thought it did, it seems like it just was using the default browser in that case. I've updated my comment above, but yeah basically:
Line 55 changed to: status = os.system('start {browser} "{url}"'.format(browser=browser, url=url))
When I click the icon, the link does open, but I also get an error saying 'Windows cannot find "whatever hyperlink". Make sure you typed the name correctly and try again."..
It is trying to open it as a windows path as well as in the browser. Might be an incompatibility with another plugin I have, but have not found it yet.