Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save brian-griffin/17d9e036db3d0568b63d to your computer and use it in GitHub Desktop.
Save brian-griffin/17d9e036db3d0568b63d to your computer and use it in GitHub Desktop.
function github {
branch="$(git rev-parse --abbrev-ref HEAD)"
url="$(git config --get remote.origin.url)"
url=${url/git@github.com:/http://github.com/}
url=${url/.git/}
if [[ $1 =~ "compare" ]]; then action="compare"
else action="tree"; fi
if [[ $2 != "" ]]; then base="$2..."
elif [[ $1 =~ "pull" ]]; then action="pull"
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