Litte shell script to setup git env
This commit is contained in:
parent
88e048f800
commit
d124b16b81
2 changed files with 34 additions and 2 deletions
|
@ -1,2 +0,0 @@
|
|||
git config --global user.name $GITUSER
|
||||
git config --global user.email $GITEMAIL
|
34
shell/setupGit.sh
Executable file
34
shell/setupGit.sh
Executable file
|
@ -0,0 +1,34 @@
|
|||
#!/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
|
Loading…
Reference in a new issue