-
-
Save fedescarpa/aa9ea3e8fa6dbe1d44b157ef90c965c4 to your computer and use it in GitHub Desktop.
Open current git repository in default browser
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/bash | |
GIT_REPO=$(git config -l | grep "remote.origin.url=git@") | |
HTTP_REPO=$(git config -l | grep "remote.origin.url=https://") | |
if [ -n "$GIT_REPO" ]; then | |
REPO=$(echo $GIT_REPO | awk 'BEGIN { FS = "git@" } { print $2 }' | awk 'BEGIN { FS = ":" } { print $1"/"$2 }') | |
else | |
if [ -n "$HTTP_REPO" ]; then | |
REPO=$(echo $HTTP_REPO | awk 'BEGIN { FS = "https://" } { print $2 }') | |
else | |
echo "GIT or HTTPS in remote.origin.url missing" | |
exit 1 | |
fi | |
fi | |
echo "Opening $REPO" | |
sensible-browser "https://$REPO" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment