Skip to content

Instantly share code, notes, and snippets.

@seveas
Created April 20, 2012 20:47
Show Gist options
  • Save seveas/2431800 to your computer and use it in GitHub Desktop.
Save seveas/2431800 to your computer and use it in GitHub Desktop.
Git config from ldap (/etc/profile.d/gitconfig.sh)
# Set git user/email based on ldap values
test -x /usr/bin/git || return
test -x /usr/bin/ldapsearch || return
git config --global user.name > /dev/null || {
name=$(ldapsearch -x -LLL "(uid=$USER)" cn | sed -ne 's/^cn: //p')
test -n "$name" && git config --global user.name "$name"
}
git config --global user.email > /dev/null || {
email=$(ldapsearch -x -LLL "(uid=$USER)" mail| sed -ne 's/^mail: //p')
test -n "$email" && git config --global user.email "$email"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment