35 lines
1.2 KiB
Bash
Executable file
35 lines
1.2 KiB
Bash
Executable file
#!/bin/sh
|
|
declare -A variables
|
|
read -p 'Git username: ' variables[gituser]
|
|
read -p 'Git email: ' variables[gitmail]
|
|
|
|
echo "The computers git username ${variables[gituser]}"
|
|
|
|
PS3='Which Git signing format? '
|
|
options=("openpgp" "ssh" )
|
|
select opt in "${options[@]}"
|
|
do
|
|
case $opt in
|
|
"openpgp")
|
|
variables[signformat]=$opt
|
|
echo Emails of currently installed secret keys:
|
|
gpg --list-secret-keys | grep uid
|
|
read -p 'Type email of secret key: ' email
|
|
variables[signingkey]=$(gpg --list-secret-keys --keyid-format=long $email | grep sec | tr " " "\n" | head -4 | tail -1 | tr "/" "\n" | head -2 | tail -1 | tr -d "\n")
|
|
break
|
|
;;
|
|
"ssh")
|
|
variables[signformat]=$opt
|
|
read -ep 'Path to public key: ' variables[signingkey]
|
|
break
|
|
;;
|
|
*) echo "invalid option $REPLY";;
|
|
esac
|
|
done
|
|
|
|
git config --global user.name ${variables[gituser]}
|
|
git config --global user.email ${variables[gitmail]}
|
|
git config --global user.signingkey ${variables[sigingkey]}
|
|
git config --global gpg.format ${variables[signformat]}
|
|
git config --global commit.gpgsign true
|