Hey hey!
There's this bash_profile
alias I've been using and probably it's helpful for you too:
For MacOS:
alias gh="open \`git remote -v | grep git@github.com | grep fetch | head -1 | cut -f2 | cut -d' ' -f1 | sed -e's/:/\//' -e 's/git@/http:\/\//'\`"
For Linux (provided by Shawn McElroy in the comments, thank you):
alias gh="$BROWSER $(git remote -v | grep git@github.com | grep fetch | head -1 | cut -f2 | cut -d' ' -f1 | sed -e's/:/\//' -e 's/git@/http:\/\//'\)"
After that, just use the command gh
. It will open your browser with the currently active Git project in Github.
Top comments (3)
In Linux there's no
open
command. You should be able to do this if your default browser is setIt may work on osx as well if you set $BROWSER in your terminal somewhere. Note, I'm on my phone so I couldn't try this but it should be right
Oh wow! Thank you! I edited the article, specified environments and added your script there.
Ooh, good point. Both should work. BROWSER may not always be set either probably