Skip to content

Instantly share code, notes, and snippets.

@seveas
Created April 20, 2012 20:47
Show Gist options
  • Select an option

  • Save seveas/2431800 to your computer and use it in GitHub Desktop.

Select an option

Save seveas/2431800 to your computer and use it in GitHub Desktop.

Revisions

  1. seveas created this gist Apr 20, 2012.
    14 changes: 14 additions & 0 deletions gitconfig.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    # 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"
    }