Description
Problem I'm dealing with
Terminal users who are not terminal savvy finding the environment variable only approach to overriding the default host logic confusing.
For multi-account users whose primary GitHub host is not github.com
, they must use GH_HOST
environment variable to target the appropriate host for core GitHub CLI commands or GitHub CLI extensions without repository context. It is also possible for core GitHub CLI commands and GitHub CLI extension authors to add support for --hostname
flag to explicitly communicate this can be set / overridden but must be added intentionally.
The problem comes in for terminal users who are not savvy to working with terminals:
-
This setting must be managed separately from hosts authenticated via
gh auth login
if the usergh auth logout
from this host, then errors occur -
Shells offer different levels of scoping environment variables
- Command-specific (
GH_HOST=... gh api ...
)
PowerShell does not support this - Session-specific (
export GH_HOST=...
) - Semi-permanent (
.zshrc
,.bashrc
,~/.config/powershell/profile.ps1
)
- Command-specific (
-
Inconsistent experiences for users unfamiliar with login sessions versus non-interactive sessions
.zprofile
vs.zshrc
,.bashrc
vs.bash_profile
Ideas to address this
What if we could indicate which host should be the default?
$ cat ~/.config/gh/hosts.yml
github.ghe.com:
default: true
git_protocol: https
users:
andyfeller:
user: andyfeller
github.com:
git_protocol: https
users:
andyfeller:
user: andyfeller
In the example above, I want to specify that github.ghe.com
is my default host in the event that the host can't be determined by repository context.
This would involve change to the following logic for determining default host:
Lines 130 to 150 in dbd982e