Created
October 1, 2016 03:12
-
-
Save saantiaguilera/4901c02fcceb291247f25ff892eb8cb2 to your computer and use it in GitHub Desktop.
Commit with gpg without having to always remember -S
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
#!/bin/bash | |
EXISTS="`git config --global --list | sed -n "/.*signingkey.*/p"`" | |
if [ -z $EXISTS ] | |
then | |
echo "Woops ! It seems you dont have your git signed. Looking for an existing GPG key..." | |
SIGNING_KEY="`gpg --list-keys | sed -n '3p' | sed "s/.*\///" | sed "s/ .*//"`" | |
if ! [ -z "$SIGNING_KEY" ]; then | |
echo "GPG Key found ! Using: $SIGNING_KEY" | |
git config --global user.signingkey "$SIGNING_KEY" | |
echo "Configured your global user with the key :)" | |
EXISTS="exists" | |
else | |
echo "GPG Key not found :( Create one with: gpg --gen-key" | |
fi | |
fi | |
if ! [ -z $EXISTS ]; then | |
git commit -S | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this to somewhere
PATH
can access. This works for OS X, best path to place it is under/usr/local/bin/
:)Remember permissions ! If you place it in
/usr/local/bin/
since everyone can have access to the scripts, give thecommit
script all type of permissions