Created
March 18, 2011 00:19
-
-
Save cspickert/875406 to your computer and use it in GitHub Desktop.
A short PyObjC script to set git-config user parameters via the Address Book Framework.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from objc import YES, NO, NULL | |
from Foundation import * | |
from AddressBook import * | |
import os | |
# Set the path to git | |
GIT = "/usr/local/bin/git" | |
# Get the current user's address book record | |
myPerson = ABAddressBook.sharedAddressBook().me() | |
# Get the user's full name | |
fullName = ' '.join(map(myPerson.valueForProperty_, [kABFirstNameProperty, kABLastNameProperty])) | |
# Get the user's primary email | |
emailProperty = myPerson.valueForProperty_(kABEmailProperty) | |
identifier = emailProperty.primaryIdentifier() | |
email = emailProperty.valueForIdentifier_(identifier) | |
# Set the appropriate settings using git-config | |
os.system("%s config --global user.name '%s'" % (GIT, fullName)) | |
os.system("%s config --global user.email '%s'" % (GIT, email)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment