Skip to content

Instantly share code, notes, and snippets.

@csexton
Last active March 24, 2017 22:50
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 csexton/2e7134e5df11afe81a9180c3af32bf72 to your computer and use it in GitHub Desktop.
Save csexton/2e7134e5df11afe81a9180c3af32bf72 to your computer and use it in GitHub Desktop.
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