EvanLovely
5/30/2014 - 8:49 PM

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 pa

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"
}