-
-
Save hail2u/1856938 to your computer and use it in GitHub Desktop.
open corresponding URL of the repository of current directory (for msys)
This file contains 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/sh | |
GIT='git' | |
FETCH_URL=`$GIT remote show origin -n | sed -n '/Fetch URL/p' | awk '{print $3}' | sed -E 's/[:@]/ /g' ` | |
HOST=`echo $FETCH_URL | awk '{print $2}' ` | |
REPOS=`echo $FETCH_URL | awk '{print $3}' | sed 's/.git$//'` | |
ORIGIN="http://$HOST/" | |
BRANCH=`$GIT branch | grep -F '*' | sed 's/^* //'` | |
echo $REPOS | 'egrep' -q '^gist/' | |
if [ $? = 0 ]; then | |
GIST=YES | |
else | |
GIST=NO | |
fi | |
if test "x$1" = "x" ; then | |
if test $GIST = "YES" ; then | |
URL="$ORIGIN$REPOS" | |
else | |
if test "x$BRANCH" = "x(no branch)"; then | |
URL="$ORIGIN$REPOS" | |
else | |
URL="$ORIGIN$REPOS/tree/$BRANCH" | |
fi | |
fi | |
else | |
if test $GIST = "YES" ; then | |
URL="$ORIGIN$REPOS/$1" | |
else | |
URL="$ORIGIN$REPOS/commit/$1" | |
fi | |
fi | |
echo $URL | |
open "$URL" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment