Package 'whoami'

Title: Username, Full Name, Email Address, 'GitHub' Username of the Current User
Description: 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.
Authors: Gábor Csárdi [aut, cre], Maëlle Salmon [ctb], Posit Software, PBC [cph, fnd]
Maintainer: Gábor Csárdi <[email protected]>
License: MIT + file LICENSE
Version: 1.3.0.9000
Built: 2024-07-05 05:31:34 UTC
Source: https://github.com/r-lib/whoami

Help Index


Email address of the current user

Description

If uses the EMAIL environment variable, if set. Otherwise it tries to find it in the user's global git configuration.

Usage

email_address(fallback = NULL)

Arguments

fallback

If not NULL then this value is returned if the email address cannot be found, instead of triggering an error.

Value

Email address on success. Otherwise an error is thrown.

See Also

Other user names: fullname(), gh_username(), username(), whoami()

Examples

## Not run: 
email_address()

## End(Not run)

Full name of the current user

Description

Uses the FULLNAME environment variable, if set. Otherwise tries system full names and the git configuration as well.

Usage

fullname(fallback = NULL)

Arguments

fallback

If not NULL then this value is returned if the full name of the user cannot be found, instead of triggering an error.

Value

The full name of the current user.

See Also

Other user names: email_address(), gh_username(), username(), whoami()

Examples

## Not run: 
fullname()

## End(Not run)

Find the current user's GitHub username

Description

Uses the GITHUB_USERNAME global variable or searches on GitHub, for the user's email address, see email_address.

Usage

gh_username(token = NULL, fallback = NULL)

Arguments

token

GitHub token to use. By default it uses the GITHUB_TOKEN environment variable, if set. If unset, uses the GITHUB_PAT environment variable, if set.

fallback

If not NULL then this value is returned if the GitHub username cannot be found, instead of triggering an error.

Details

This function caches the username in the current R session, and if the email address of the user is unchanged, it does not perform another GitHub query.

Value

GitHub username, or an error is thrown if it cannot be found.

See Also

Other user names: email_address(), fullname(), username(), whoami()

Examples

## Not run: 
gh_username()

## End(Not run)

User name of the current user

Description

Tries the LOGNAME, USER, LNAME, USERNAME environment variables first. Then it tries the id command on Unix-like platforms and whoami on Windows.

Usage

username(fallback = NULL)

Arguments

fallback

If not NULL then this value is returned if the username cannot be found, instead of triggering an error.

Value

The user name of the current user.

See Also

Other user names: email_address(), fullname(), gh_username(), whoami()

Examples

## Not run: 
username()

## End(Not run)

User name and full name of the current user

Description

Calls username and fullname.

Usage

whoami()

Details

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.

Value

A named character vector with entries: username, fullname, email_address, gh_username.

See Also

Other user names: email_address(), fullname(), gh_username(), username()

Examples

## Not run: 
whoami()

## End(Not run)