Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use custom browser in st2 and ubuntu + url wrapped in arbitrary symbols #29

Closed
simov opened this issue Apr 19, 2015 · 1 comment
Closed

Comments

@simov
Copy link

simov commented Apr 19, 2015

I was about to submit a PR but this package doesn't seems to be actively maintained, so here are two fixes that might help someone.

Use custom browser in st2 and ubuntu

This package was opening my links with st2 in FF even though I have Chrome set as default browser on Ubuntu. So I stumbled upon this thread and I edited my /home/[USER]/.config/sublime-text-2/Packages/Open URL/open_url.py

else:
  wb = webbrowser.get('/usr/bin/google-chrome %s')
  if "://" in url:
    wb.open_new_tab(url)
  elif re.search(r"\w[^\s]*\.(?:com|co|uk|gov|edu|tv|net|org|tel|me|us|mobi|es|io)[^\s]*\Z", url):
    if not "://" in url:
      url = "http://" + url
    wb.open_new_tab(url)
  else:
    url = "http://google.com/#q=" + urllib.quote(url, '')
    wb.open_new_tab(url)

This one opens up the links in Chrome on Linux. Of course that's hardcoded but I'm pretty sure you can figure out how to modify it to work with your own OS and browser.

URL wrapped in arbitrary symbols

This is how you can strip any symbols that your url is wrapped with:

# strip quotes if quoted
if (url.startswith("\"") & url.endswith("\"")) | (url.startswith("\'") & url.endswith("\'")) | (url.startswith("`") & url.endswith("`")):

The added bits are

| (url.startswith("`") & url.endswith("`"))

So for example you can add

 | (url.startswith("{") & url.endswith("}"))

for links wrapped like this {http://some.url} and so on.

@kylebebak
Copy link
Collaborator

Hey @simov , this issue is fixed in 1.1.0. You can setdelimiters in your settings to tell the plugin when to stop automatically expanding the selection.

The default delimiters are \t\n\r\"'`,*<>[](). All the characters you mentioned above are included!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants