Skip to content

Instantly share code, notes, and snippets.

@ches
Created April 4, 2009 02:04
Show Gist options
  • Select an option

  • Save ches/90083 to your computer and use it in GitHub Desktop.

Select an option

Save ches/90083 to your computer and use it in GitHub Desktop.

Revisions

  1. ches revised this gist Apr 4, 2009. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion snippet.sh
    Original file line number Diff line number Diff line change
    @@ -1 +1,4 @@
    alias github='br=$(git branch --contains HEAD | sed -En "s/^\* //p"); open $(git config -l | sed -En "s%remote.origin.url=git(@|://)(github.com)(:|/)(.+/.+).git%https://\2/\4/tree/${br}%p")'
    # 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")'
  2. ches revised this gist Apr 4, 2009. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion snippet.sh
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    alias github='br=$(git branch --contains HEAD | sed -En "s/^\* //p"); open $(git config -l | grep "remote.origin.url" | sed -En "s%remote.origin.url=git(@|://)(github.com)(:|/)(.+/.+).git%https://\2/\4/tree/${br}%p")'
    alias github='br=$(git branch --contains HEAD | sed -En "s/^\* //p"); open $(git config -l | sed -En "s%remote.origin.url=git(@|://)(github.com)(:|/)(.+/.+).git%https://\2/\4/tree/${br}%p")'
  3. ches revised this gist Apr 4, 2009. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion snippet.sh
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    alias github='br=$(git branch --contains HEAD | sed -En "s/^\* //p"); open $(git config -l | grep "remote.origin.url" | sed -En "s/remote.origin.url=git(@|:\/\/)github.com(:|\/)(.+)\/(.+).git/https:\/\/github.com\/\3\/\4\/tree\/${br}/p")'
    alias github='br=$(git branch --contains HEAD | sed -En "s/^\* //p"); open $(git config -l | grep "remote.origin.url" | sed -En "s%remote.origin.url=git(@|://)(github.com)(:|/)(.+/.+).git%https://\2/\4/tree/${br}%p")'
  4. ches created this gist Apr 4, 2009.
    1 change: 1 addition & 0 deletions snippet.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    alias github='br=$(git branch --contains HEAD | sed -En "s/^\* //p"); open $(git config -l | grep "remote.origin.url" | sed -En "s/remote.origin.url=git(@|:\/\/)github.com(:|\/)(.+)\/(.+).git/https:\/\/github.com\/\3\/\4\/tree\/${br}/p")'