Skip to content

Instantly share code, notes, and snippets.

@victormartins
Forked from andrewjtait/gist:9114245e92b84d69aa43
Last active August 29, 2015 14:18
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 victormartins/777c2311a7fd66f5af47 to your computer and use it in GitHub Desktop.
Save victormartins/777c2311a7fd66f5af47 to your computer and use it in GitHub Desktop.
function github {
branch="$(git rev-parse --abbrev-ref HEAD)"
url="$(git config --get remote.upstream.url)"
url=${url/git@github.com:/http://github.com/}
url=${url/.git/}
if [[ $1 =~ "compare" ]]; then action="compare"
elif [[ $1 =~ "pr" ]]; then action="pull"
else action="tree"; fi
if [[ $2 != "" ]]; then base="$2..."
else base=""; fi
url="${url}/${action}/${base}${branch}"
echo "Opening ${url} $(\open ${url})"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment