gh api user --jq '.login'

Category: GitHub CLI

gh api user --jq '.login'

Print your GitHub username via API

GETs the authenticated user endpoint and --jq extracts the login field. The leading slash is optional in gh api paths. This is a quick identity check that also confirms your token works.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.