Last active
April 8, 2017 01:33
-
-
Save stefansundin/2d91d45580763cda29af to your computer and use it in GitHub Desktop.
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 | |
# https://gist.github.com/stefansundin/2d91d45580763cda29af | |
# Easily open a repo in a browser, just run `git open` | |
# Linux users need to change "open" to "xdg-open". | |
# Example installation instructions: | |
# curl -fL -o /usr/local/bin/git-open https://gist.githubusercontent.com/stefansundin/2d91d45580763cda29af/raw/git-open | |
# chmod +x /usr/local/bin/git-open | |
ORIGIN=`git config --get remote.origin.url | sed -e 's/\.git$//'` | |
if [ -z "$ORIGIN" ]; then | |
echo "This repository doesn't seem to have an origin remote configured." | |
exit 1 | |
fi | |
if [[ "$ORIGIN" == "http"* ]]; then | |
# http origin | |
echo "$ORIGIN" | |
open "$ORIGIN" | |
else | |
# ssh origin | |
URL=`echo "$ORIGIN" | sed -e 's/:/\//' -e 's/[^@]*@/https:\/\//'` | |
echo "$URL" | |
open "$URL" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment