Created
May 30, 2014 20:49
-
-
Save EvanLovely/19e1072914e14e446aff to your computer and use it in GitHub Desktop.
Open the web page from which this git repo was cloned. Place in ~/.bash_functions. Then type `opengiturl` in any Git Repo to open the web page from which it was cloned.
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
# Open the web page from which this git repo was cloned | |
opengiturl() { | |
i="$(git config --get remote.origin.url)" | |
if [[ "$(echo $?)" != "0" ]]; then | |
echo "Not a Git Repository" | |
return 1 | |
fi | |
if [[ "$i" == "git"* ]]; then | |
url="$(echo "$i" | sed 's,.git$,,' | sed 's,:,/,' | sed 's,^git@,http://,')" | |
else | |
url="$(echo "$i" | sed 's,.git$,,')" | |
fi | |
echo "$i" | pbcopy | |
echo "Git Remote: $i" | |
echo "Web URL: $url" | |
echo "Git Remote Copied & Web URL Opening..." | |
open "$url" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment