-
Notifications
You must be signed in to change notification settings - Fork 0
/
credentials.sh
52 lines (44 loc) · 1.12 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
#!/bin/bash
# This script provides one-stop shopping for entering your credentials.
# Please run this script when you reset the Docker container.
# The "git commit" command will not work without your Git credentials.
# 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
}
echo '***********************'
echo 'SETTING GIT CREDENTIALS'
EMAIL_DEF='you@example.com'
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"
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