Last active
November 27, 2019 23:54
-
-
Save anson-vandoren/adb48de6130eeacf27ec8f545d839cf6 to your computer and use it in GitHub Desktop.
Private configuration for dotfiles
This file contains hidden or 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
GIT_AUTHOR_NAME="Your Name" | |
GIT_AUTHOR_EMAIL="[email protected]" | |
# if there is no username set, set it now | |
if ! git config --list | grep -q "user.name"; then | |
git config --file ~/.gitconfig_private user.name "$GIT_AUTHOR_NAME" | |
fi | |
# if there is no user email set, set it now | |
if ! git config --list | grep -q "user.email"; then | |
git config --file ~/.gitconfig_private user.email "$GIT_AUTHOR_EMAIL" | |
fi | |
# if there is no signing key set, try to set it now with user permission | |
if ! git config --list | grep -q "user.signingkey"; then | |
# get gpg signing key | |
keyid_regex="sec.+rsa4096/([^ ]+)" | |
keys=$(gpg --list-secret-keys --keyid-format long) | |
signingKey=$(echo $keys | grep -Ei "sec.+rsa4096/([^ ]+)" | cut -d / -f 2 | cut -d ' ' -f 1) | |
echo "Found gpg keys below" | |
echo $keys | |
echo "keyId $signingKey will be used for git." | |
echo "Is this OK? (y/n)" | |
read -r response | |
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then | |
git config --file ~/.gitconfig_private user.signingkey $signingKey | |
echo "Set signing key" | |
else | |
echo "Did not set signing key" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment