Created
December 25, 2022 08:43
-
-
Save xiaolai/11b507ad0550511da3c3675791cf0a7e to your computer and use it in GitHub Desktop.
Bash Function to Open a Gepo's Github Page from Terminal
This file contains 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
function github { | |
if [ -d .git ]; then | |
remotes=$(git remote -v | head -1 | awk -F'[email protected]:' '{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