-
Notifications
You must be signed in to change notification settings - Fork 36
/
git.sh
executable file
·42 lines (34 loc) · 1.06 KB
/
git.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env bash
# Stop on error.
set -e
source env.sh
source realname-and-email.sh
# Determine whether to set globally or locally.
OLD_PWD="$(pwd)"
if [[ -z "$1" ]]
then
echo "Signing git commits & tags ${GREEN}${BOLD}GLOBALLY${RESET}"
SCOPE="--global"
else
echo "Signing git commits & tags ${GREEN}${BOLD}LOCALLY${RESET}: $1"
SCOPE="--local"
cd "$1"
fi
source "$OLD_PWD"/lib/git_conf.sh
cd "$OLD_PWD"
# If scope local, only configure git, and don't try to push the key
# to github and set up the notifications
if [[ "${SCOPE}" == "--local" ]]; then
exit 0
fi
# Export GPG public key to GitHub.
echo "Exporting your GPG public key to GitHub."
$GPG --armor --export "$KEYID" | $CLIP $CLIP_ARGS
echo "It has been copied to your clipboard."
echo "${YELLOW}You may now add it to GitHub: https://github.com/settings/gpg/new${RESET}"
echo "${GREEN}Opening GitHub...${RESET}"
$OPEN "https://github.com/settings/gpg/new"
echo
# Turn on notifications.
source lib/notifications.sh $SCOPE
echo "${GREEN}Enjoy signing your git commits with your YubiKey!${RESET}"