DEV Community

Discussion on: Open the GitHub project page of a repo from Terminal

Collapse
 
jotarios profile image
Jorge Rios • Edited

Hi guys, this my own version for ssh and https, in one line, also you can run it in a subdirectory:


bash
function GitHub()
{
    git_url=`git config --get remote.origin.url`
    url=`echo $git_url | sed -e "s/git@github.com:/https:\/\/github.com\//"`
    if [[ $url != https://github* ]] ;
        then echo "ERROR: Remote origin is invalid" && return false;
    fi
    # url=${git_url%.git}
    # Use "open $url" if you use MacOS
    # Use x-www-browser if you use GNU/Linux
    x-www-browser $url
}
Enter fullscreen mode Exit fullscreen mode