So if..
$ git config user.name
↳ Alex Gray # OK (my name)
$ git config user.email
↳ alex@mrgray.com # OK (my email).
and..
GithubUserForProject() { # in pwd
ORIGIN=$(git config --get remote.origin.url) && echo $ORIGIN
OWNER=${ORIGIN%/*} && echo $OWNER # trim URL tail
OWNER=${OWNER#*.com/} && echo $OWNER # trim URL head
OWNER=${OWNER#*:} && echo $OWNER # trim ssh URL head
}
$ cd /local/git/MyGitHubRepo && GithubUserForProject
↓ git@github.com:mralexgray/MyGitHubRepo.git
↓ git@github.com:mralexgray
↳ mralexgray # OK (my username, but skanky way of finding it)
but…
$ cd /local/git/SomeGuysProject && GithubUserForProject
↓ git://github.com/someguy/SomeGuysProject.git
↓ git://github.com/someguy
↳ someguy # WRONG! (cloned repo's user!)
So, how can I determine my github “short username” programmatically, either from the environment, a github API request, etc., or otherwise (via a script or terminal session?
I thought it silly that such an inane question go so glaringly unsolved… so for lack of knowing how to cleverly parse strings in bash without resorting to the one
SEDcombo I know by heart, and……security find-internet-password -s github.com | grep acct | sed 's/"acct"<blob>="//g' | sed 's/"//g'ét voila….
mralexgrayThis may depend on having the Github mac client installed… and yet again… it might not.