gitfetch icon indicating copy to clipboard operation
gitfetch copied to clipboard

Use the authenticated user as default user

Open noirbizarre opened this issue 1 year ago • 6 comments

Hi 👋🏼

Given the GitHub CLI need to be authenticated, there is already a default me user.

So maybe the initial default user prompt can be removed and:

  • use the authenticated user as default user
  • keep the ability to set a different default user from conf

noirbizarre avatar Oct 20 '25 12:10 noirbizarre

+1, why do we need to provide username/password upon installation if thats already done via the dh login command?

0xjuanma avatar Oct 20 '25 14:10 0xjuanma

+1 you already get the output of the gh auth status here

and in that output there is a username:

github.com
  ✓ Logged in to github.com as Zeviraty (/home/zev/.config/gh/hosts.yml)
  ✓ Git operations for github.com configured to use ssh protocol.
  ✓ Token: gho_************************************
  ✓ Token scopes: admin:public_key, delete_repo, gist, read:org, repo

and you can use this regex to get it: ✓ Logged in to github\.com as ([A-Za-z]+) \([^)]*\) the resulting first capture group returning the username

Zeviraty avatar Oct 20 '25 16:10 Zeviraty

Actually, you can directly have this as a JSON-formatted output:

$ gh auth status --json hosts
{
  "hosts": {
    "github.com": [
      {
        "state": "success",
        "active": true,
        "host": "github.com",
        "login": "my-username",
        "tokenSource": "GH_TOKEN",
        "scopes": "...",
        "gitProtocol": "ssh"
      }
    ]
  }
}

noirbizarre avatar Oct 20 '25 16:10 noirbizarre

Oh didnt notice that but the one i posted could be helpfull because the command is already executed but if not, that is better

Zeviraty avatar Oct 20 '25 17:10 Zeviraty

It should not ask for gh authentication on installation with the latest release, however you still need to authenticate after.

Matars avatar Oct 20 '25 18:10 Matars

@noirbizarre thanks for the tip - I ended up using that approach.

Matars avatar Oct 20 '25 18:10 Matars