-
Notifications
You must be signed in to change notification settings - Fork 0
/
credentials.sh
61 lines (53 loc) · 1.22 KB
/
credentials.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
# Output:
# First argument if it is not blank
# Second argument if first argument is blank
anti_blank () {
if [ -z "$1" ]; then
echo "$2"
else
echo "$1"
fi
}
# Setting Git email if necessary
GIT_EMAIL="$(git config user.email)"
if [ -z "$GIT_EMAIL" ]; then
EMAIL_DEF='[email protected]'
echo
echo "Default email address: ${EMAIL_DEF}"
echo
echo 'Enter your Git email address:'
read EMAIL_SEL
EMAIL=$(anti_blank $EMAIL_SEL $EMAIL_DEF)
echo
echo
echo '------------------------------'
echo "git config --global user.email"
echo "$EMAIL"
git config --global user.email "$EMAIL"
fi
# Setting Git name if necessary
GIT_NAME="$(git config user.name)"
if [ -z "$GIT_NAME" ]; then
NAME_DEF='Your Name'
echo
echo "Default name: ${NAME_DEF}"
echo
echo 'Enter your Git name:'
read NAME_SEL
# NOTE: The double quotes are needed to avoid truncating the string
# at the space.
NAME=$(anti_blank "$NAME_SEL" "$NAME_DEF")
echo
echo '-----------------------------'
echo "git config --global user.name"
echo "$NAME"
git config --global user.name "$NAME"
echo
fi
echo '------------'
echo 'heroku login'
heroku login
echo '---------------'
echo 'heroku keys:add'
heroku keys:add