Skip to content

Instantly share code, notes, and snippets.

@xiaolai
Created December 25, 2022 08:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xiaolai/11b507ad0550511da3c3675791cf0a7e to your computer and use it in GitHub Desktop.
Save xiaolai/11b507ad0550511da3c3675791cf0a7e to your computer and use it in GitHub Desktop.
Bash Function to Open a Gepo's Github Page from Terminal
function github {
if [ -d .git ]; then
remotes=$(git remote -v | head -1 | awk -F'git@github.com:' '{print $2}' | cut -d" " -f1)
if [ -z "$remotes" ];
then
remotes=$(git remote -v | awk -F'https://github.com/' '{print $2}' | cut -d" " -f1)
fi
remote_url=$(echo $remotes | cut -d" " -f1)
url="https://github.com/"
url="${url}${remote_url}"
open $url
else
echo "Not a git repo"
fi;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment