Skip to content

Instantly share code, notes, and snippets.

@bestie
Created December 15, 2014 13:20
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 bestie/f3e25c91d85592449280 to your computer and use it in GitHub Desktop.
Save bestie/f3e25c91d85592449280 to your computer and use it in GitHub Desktop.
$ gh # Open this repo on Github
#!/usr/bin/env ruby
organization, repo = %x[git remote --verbose]
.each_line
.select { |line| line.include?("origin") }
.select { |line| line.include?("fetch") }
.select { |line| line.include?("github.com") }
.map { |line| line.match(%r{github.com:([^/]+)/([^/]+)\.git})[1..-1] }
.first || ["drupal"] * 2
github_url = "https://github.com/#{organization}/#{repo}"
pr_url = [github_url, "pulls"].join("/")
sub_command = ARGV[0]
case sub_command
when "p"
url = pr_url
else
url = github_url
end
exec(%{open '#{url}'})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment