-
-
Save bestie/f3e25c91d85592449280 to your computer and use it in GitHub Desktop.
$ gh # Open this repo on Github
This file contains 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 | |
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