-
-
Save weapp/4717249 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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