Skip to content

Instantly share code, notes, and snippets.

@weapp
Forked from fenprace/install.sh
Last active December 12, 2015 04:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weapp/4717249 to your computer and use it in GitHub Desktop.
Save weapp/4717249 to your computer and use it in GitHub Desktop.
#!/bin/sh
sudo mv /usr/bin/xdg-open /usr/bin/xdg-open.bak
sudo curl https://gist.github.com/weapp/4717249/raw/16b3ce7ae4c4e63162ca0d9e47b2805d410bfa14/xdg-open.rb -o /usr/bin/xdg-open
sudo chmod a+x /usr/bin/xdg-open
#!/usr/bin/env ruby
require 'cgi'
require 'uri'
def parse(text)
uri = URI(text)
info = CGI::parse uri.query
info['url'] = URI(info['url'][0]).path
info
end
def launch(path, line)
system "subl #{path}:#{line}"
end
address = ARGV.first
if address =~ /^subl\:\/\//
result = parse(address)
launch result['url'], result['line']
else
system "/usr/bin/xdg-open.bak #{address}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment