November 18, 2013

Open URL from Sublime Text

I keep a lot of text files to track progress/notes on projects with a lot of URLs.  For some notes, it has too many URLs and it became a hassle to copy&paste in a browser to check the page.  I found this handy tool for the purpose:

I tried on Mac and Windows -- and it works quite well. 

The installation steps are straight forward and well explained -- but I'm just entering the steps here as a note to myself.  You'll need GIT client for your OS to follow below step.

For Windows:
  1. Open Sublime Text
  2. Press CTRL+`
  3. Copy and paste (for Sublime Text 2) this (see
    import urllib2,os; pf='Package Control.sublime-package'; ipp = sublime.installed_packages_path(); os.makedirs( ipp ) if not os.path.exists(ipp) else None; urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler( ))); open( os.path.join( ipp, pf), 'wb' ).write( urllib2.urlopen( '' +pf.replace( ' ','%20' )).read()); print( 'Please restart Sublime Text to finish installation')
  4. Restart Sublime Test
  5. Select from menu, Preferences -> Browser Packages.  This will open a folder -- for my case, it is "C:\Users\kkim\AppData\Roaming\Sublime Text 2\Packages"
  6. Open cmd in that folder (or move to that directory)
  7. Run git command (see the above open-url github page):
    git clone --branch st2
  8. Restart Sublime Text.
Use CTRL-u or ALT-double click on URL in text file to open the web page using default browser.

No comments: