Skip to content

Instantly share code, notes, and snippets.

@EvanLovely
Created May 30, 2014 20:49
Show Gist options
  • Save EvanLovely/19e1072914e14e446aff to your computer and use it in GitHub Desktop.
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.
# 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