-
-
Save zph/6b0171954c36146e307e 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
#!/usr/bin/env sh | |
# git-browse, the @bantik revision with banter by @ZPH | |
git config --get remote.origin.url | \ | |
ruby -ne 'puts %{https://github.com/#{$_.split(/.com[\:\/]/)[-1].gsub(".git","")}}' | \ | |
xargs open |
Fails on [email protected]:AptsCom/reporting-webclient.git, the result is https://github.com/ApsCom/reporn-webclen
Trying another rev...
=) True!
Very fun!
Wouldn't be much of a one liner anymore, but we could make it capture the url (ie handle non-github pages, like bitbucket.org) via regex and use that for building final URL.
Gimme a min.
git config --get remote.origin.url | ruby -ne 'puts %{https://github.com/#{$_.split(/.com[\:\/]/)[-1].gsub(".git","")}}' | xargs open
%r{(?<hostname_url>[\.\w]+)[/:](?<username>[-\w]+)/(?<repo>[-\w]+)}
How's that for a work of art?
Yours looks like it works for either configuration as long as it's a github location 😄
In honor of my new method of the day, you could even replace .gsub with .delete(".git")
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sweet, let's keep this going. It's fun. :)