Skip to content

Instantly share code, notes, and snippets.

@csexton csexton/
Last active Mar 24, 2017

What would you like to do?
Do you even git, bro?

Step 1: Save the script to some place in your $PATH and make it executable.

Step 2: git config --global alias.bro '!git-browse'

Step 3: When everyou want to view a branch on github, just git bro

#!/usr/bin/env ruby
repo = `git config --get remote.origin.url`.strip
branch = `git branch | sed -n '/\* /s///p'`.strip
repo_url = repo.sub(':', '/').sub(/^git@/, 'https://').sub(/(.*)\.git/, '\1')
repo_url = "#{repo_url}/tree/#{branch}"
# This only works on a mac. Send pull requests!
`open #{repo_url}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.