Created
May 1, 2023 02:15
-
-
Save Sanix-Darker/b073497cd5816fec6ea1ccf1fd0c5833 to your computer and use it in GitHub Desktop.
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
git_open_link(){ | |
# $1 can be 'origin' or 'dev' depending on the source | |
remote_link=$(git remote get-url $1) | |
browser=firefox | |
CURL_CHECK="curl --head --silent --fail" | |
if $CURL_CHECK "$remote_link" &> /dev/null; then | |
$browser $remote_link; | |
else | |
built_link=$(echo "https://$(echo $remote_link | sed -e 's/git@//' | sed -e 's/:/\//')") | |
if $CURL_CHECK "$built_link" &> /dev/null; then | |
echo "> opening '$built_link'..."; | |
$browser $built_link; | |
else | |
echo "< bad link : $built_link"; | |
fi; | |
fi; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment