gh cli current auth user item
Describe the solution you'd like
A simple github item that shows the user I am currently authenticated as on the gh cli.
Additional context
I have tried to create one, but the prompt is "weird.
function _tide_item_gh
_tide_print_item gh $tide_gh_icon' ' (gh api user -q ".login")
end
set -U tide_gh_color CCFF00
set -U tide_gh_bg_color normal
set -U tide_gh_icon 
It shows like this
There is also an issue if I run
gh auth switch, it will show the old user for one prompt. But I think that is minor.
I know this issue is old 😅, but I was looking into this for myself as well, the gh api user -q '.login' ends up making a network request. It may actually render the correct user after a slight delay without needing to show the prompt again (there's a background job that runs for async refresh, it may be taking longer due to the network call).
There's a ~/.config/gh/hosts.yml which has the actively signed in user. Reading from there, it should avoid the network request and refresh immediately.
function _tide_item_gh
set -l gh_hosts_file ~/.config/gh/hosts.yml
set -l user
if test -f $gh_hosts_file
# Grabbing user with regex pattern (not ideal, but works).
set user (cat $gh_hosts_file | string match -rg '^[ ]*user:[ ]*(.+)$')
end
if test -n "$user"
_tide_print_item gh_user $tide_gh_icon' '$user
end
end
For the prompt appearance (color issues), you have the background (bg) color set to normal set -U tide_gh_bg_color normal, you'll want to set that to something else to get it to match your theme colors.