Describe the feature or problem you’d like to solve
I manage multiple GitHub accounts across several projects and must manually run gh auth switch to change identities or explicitly set a flag to choose which authenticated account to use. I often forget to switch, which leads to accidental operations under the wrong account and interrupts my workflow. I would like to set an environment variable in my current workspace to instruct/hint gh CLI which user it should use.
Proposed solution
When multiple users are authenticated, gh should respect an environment variable (e.g. GH_USER) to pick the active user non-interactively, similar to AWS CLI's AWS_PROFILE.
Additional context
$ gh auth status
github.com
✓ Logged in to github.com account gringolito (keyring)
- Active account: false
- Git operations protocol: https
- Token: ************************************
- Token scopes: **********************************
✓ Logged in to github.com account Filipe-Utzig (keyring)
- Active account: true
- Git operations protocol: https
- Token: ************************************
- Token scopes: **********************************
$ export GH_USER=gringolito
$ gh api /user | jq -r ".login"
gringolito
$ export GH_USER=Filipe-Utzig
$ gh api /user | jq -r ".login"
Filipe-Utzig
Describe the feature or problem you’d like to solve
I manage multiple GitHub accounts across several projects and must manually run
gh auth switchto change identities or explicitly set a flag to choose which authenticated account to use. I often forget to switch, which leads to accidental operations under the wrong account and interrupts my workflow. I would like to set an environment variable in my current workspace to instruct/hint gh CLI which user it should use.Proposed solution
When multiple users are authenticated, gh should respect an environment variable (e.g. GH_USER) to pick the active user non-interactively, similar to AWS CLI's AWS_PROFILE.
Additional context