Username, Full Name, Email Address, 'GitHub' Username of the Current User

Look up the username and full name of the current user, the current user's email address and 'GitHub' username, using various sources of system and configuration information.


Linux Build Status Windows Build status CRAN RStudio mirror downloads Coverage Status

For the username it tries the LOGNAME, USER, LNAME and USERNAME environment variables first. If these are all unset, or set to an empty string, then it tries running id on Unix-like systems and whoami on Windows.

For the full name of the user, it queries the system services and also tries the user's global git configuration. On Windows, it tries finding the global git configuration in Sys.getenv("USERPROFILE") if it doesn't find it in Sys.getenv("HOME") (often "Documents").

For the email address it uses the user's global git configuration. It tries finding the global git configuration in Sys.getenv("USERPROFILE") if it doesn't find it in Sys.getenv("HOME").

For the GitHub username it uses the GITHUB_USERNAME environment variable then it tries searching on GitHub for the user's email address.

Related JavaScript packages: sindresorhus/username, sindresorhus/fullname, sindresorhus/github-username, paulirish/github-email.

Installation

devtools::install_github("r-lib/whoami")

Usage

library(whoami)
username()
#> [1] "gaborcsardi"
fullname()
#> [1] "Gabor Csardi"
email_address()
#> [1] "[email protected]"
gh_username()
#> [1] "gaborcsardi"
whoami()
#>                 username                 fullname            email_address 
#>            "gaborcsardi"           "Gabor Csardi" "[email protected]" 
#>              gh_username 
#>            "gaborcsardi"

License

MIT © Gábor Csárdi

News

1.2.0

  • gh_username() caches the result, separately for each email address.

  • gh_username() uses the GITHUB_USERNAME environment variable, if it it is set (#6, @maelle)

  • On Windows, gh_fullname() and gh_email_address() try finding the global git configuration in Sys.getenv("USERPROFILE") if it is not found in Sys.getenv("HOME") (#7, @maelle)

  • gh_username() also tries the GITHUB_PAT environment variable to find a GitHub token, after GITHUB_TOKEN (#9, @maelle)

1.1.2

Maintainence release, no user visible changes

1.1.1

Maintainence release, no user visible changes

1.1.0

  • Fallbacks, instead of errors, #2

1.0.0

First release

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("whoami")

1.2.0 by Gábor Csárdi, 4 months ago


https://github.com/r-lib/whoami#readme


Report a bug at https://github.com/r-lib/whoami/issues


Browse source code at https://github.com/cran/whoami


Authors: Gábor Csárdi [aut, cre] , Maëlle Salmon [ctb]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports httr, jsonlite, utils

Suggests covr, mockery, testthat


Imported by dataMaid, goodpractice, poio, rhub.

Suggested by desc, pkgKitten.


See at CRAN