Skip to content

Instantly share code, notes, and snippets.

@ches
Created April 4, 2009 02:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save ches/90083 to your computer and use it in GitHub Desktop.
Save ches/90083 to your computer and use it in GitHub Desktop.
Bash alias to open Github page for project and active branch in current working directory.
# Bash alias to open Github page for project in current working directory.
# Will use the current active branch if it exists remotely, or falls back to master.
alias github='br=$(git branch --contains HEAD | sed -En "s/^\* //p"); if ! git ls-remote . | grep -q -e "refs/remotes/.*/${br}"; then br="master"; fi; open $(git config -l | sed -En "s%remote.origin.url=git(@|://)(github.com)(:|/)(.+/.+).git%https://\2/\4/tree/${br}%p")'
@TheDeveloper
Copy link

Good job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment