Created
December 22, 2017 18:28
-
-
Save broofa/15e1bf47b1d37d2bbc67e24f4f84e734 to your computer and use it in GitHub Desktop.
Open GitHub web page on to current repo+branch+file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# File: git-hub | |
# | |
# Description: Open github webpage for the current repo+branch[+file] | |
# (for MacOSX, not tested on other platforms) | |
# | |
# Usage: git hub | |
# git hub <file> | |
# | |
# Installation: Save as "git-hub" in a directory in your PATH, then `chmod a+x git-hub` | |
ROOT=`git rev-parse --show-toplevel` | |
BRANCH=`git branch -vv | grep "^*" | sed -Ee "s/^\* *| .*//g"` | |
GDIR=`realpath --relative-to="${ROOT}" .` | |
URL=`git config --get remote.origin.url | sed -e "s/[^@]*@\([^:]*\):\(.*\)\.git/https:\/\/\1\/\2/"` | |
open $URL/tree/$BRANCH/$GDIR/$1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment