Skip to content

userName ​

userName returns the active user's login name (e.g. "ada").

SignatureuserName(): string
tyrus
import { userName } from "tyrus:os";

const user: string = userName();
print(`logged in as ${user}`);

Never fails the program

Falls back to "unknown" if it cannot be determined, rather than aborting the program.

See also whoami, which returns the real name instead of the login.