Alex Cory
Alex Cory

Reputation: 11865

How to get the name and person/org of the current repo for use in .gitconfig?

Basically what I'm trying to do is have a handy tool where I can say:

git open

This will just open up the current github repository in your browser. If I can get the name I could just use an alias with https://github.com/{user or org}/{repo name}.

Upvotes: 3

Views: 2444

Answers (2)

Jiri Kremser
Jiri Kremser

Reputation: 12837

try this bash function

For Linux:

function git-open-url(){
  xdg-open `git config --get remote.origin.url`
}

For Mac:

function git-open-url(){
  open `git config --get remote.origin.url`
}

Upvotes: 4

Alex Cory
Alex Cory

Reputation: 11865

I've seen the git-open tool. It's pretty cool, but I just wanted a little line in my .gitconfig so here's what I ended up doing.

[alias]
    open = "!open https://github.com/$(echo $(git remote get-url origin) | cut -f2 -d\":\")"

Works perfectly :)

Upvotes: 0

Related Questions