Skip to content

Instantly share code, notes, and snippets.

@Sanix-Darker
Created May 1, 2023 02:15
Show Gist options
  • Save Sanix-Darker/b073497cd5816fec6ea1ccf1fd0c5833 to your computer and use it in GitHub Desktop.
Save Sanix-Darker/b073497cd5816fec6ea1ccf1fd0c5833 to your computer and use it in GitHub Desktop.
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