Search code examples
macosbash

Access The Current User Email and Name from the Bash in Mac OS X


Is it possible to access the current user's name and email address from the command line in OS X? If so, how would it be done?


Solution

  • There's an open-source CLI app to interact with Contacts (previously known as Address Book).

    https://github.com/dhess/contacts

    Email of Current User

    contacts -Hm -f '%e'
    

    Name of Current User

    contacts -Hm -f '%n'