Skip to content

Instantly share code, notes, and snippets.

@chulkilee
Created October 23, 2013 22:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chulkilee/7128176 to your computer and use it in GitHub Desktop.
Save chulkilee/7128176 to your computer and use it in GitHub Desktop.
Open git remote in browser (mac)
#!/bin/bash
REMOTE=$1
if [[ -z "$REMOTE" ]] ; then
REMOTE='origin'
fi
PARSED=$(git remote -v | grep '(fetch)' | grep "^$REMOTE\t" | awk -F "\t| " '{print $2}' | sed -E -e 's/\.git$//' -e 's/^.+@//')
if [[ -z "$PARSED" ]] ; then
echo "Cannot find git remote: $REMOTE"
exit
fi
if [[ $PARSED == http* ]] ; then
URL=$PARSED
else
PARSED=$(echo $PARSED | sed 's/:/\//')
URL="http://$PARSED"
fi
open $URL # Mac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment