Skip to content

Instantly share code, notes, and snippets.

@stefanpenner
Created July 24, 2012 14:10
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 stefanpenner/3170094 to your computer and use it in GitHub Desktop.
Save stefanpenner/3170094 to your computer and use it in GitHub Desktop.
function git-web-compare(){
# Usage:
# cd <git_repo>
# git-web-compare <user/repo>
# -> copies url into clipboard
# -> opens browser window at url
#
# Example:
# cd rails
# git-web-compare rails/rails
# -> magick
local date=1.days
local last=$(git branch | grep '*' | cut -d ' ' -f 2-2)
local first=$(git log --pretty=oneline --since $date | cut -d ' ' -f 1-1 | tail -1)
local url="https://github.com/$1/compare/$first...$last"
echo $url
echo $url | pbcopy
open $url
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment