Skip to content

Instantly share code, notes, and snippets.

@zph

zph/git-browse Secret

Last active December 19, 2015 19:18
Show Gist options
  • Save zph/6b0171954c36146e307e to your computer and use it in GitHub Desktop.
Save zph/6b0171954c36146e307e to your computer and use it in GitHub Desktop.
#!/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
@zph
Copy link
Author

zph commented Jul 16, 2013

%r{(?<hostname_url>[\.\w]+)[/:](?<username>[-\w]+)/(?<repo>[-\w]+)}

How's that for a work of art?

@zph
Copy link
Author

zph commented Jul 16, 2013

Yours looks like it works for either configuration as long as it's a github location 😄

@zph
Copy link
Author

zph commented Jul 16, 2013

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