-
Notifications
You must be signed in to change notification settings - Fork 0
/
git_identity.sh
executable file
·71 lines (66 loc) · 1.58 KB
/
git_identity.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
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env bash
# Colors
NC="\033[0m"
GREEN="\033[1;32m"
YELLOW="\033[1;33m"
# Check Git Identity Variables
GIT_USERNAME="$(git config user.name)"
GIT_EMAIL="$(git config user.email)"
function GET_IDENTITY() {
if [[ "${TEMP}" == "y" ]]; then
echo ""
echo -e "${YELLOW}Kindly enter your Git Email${NC}"
read -r EMAIL
echo ""
echo -e "${YELLOW}Kindly enter your Git Name${NC}"
read -r USERNAME
echo ""
echo -e "${YELLOW}Entered Details are: -${NC}"
echo ""
echo -e "${YELLOW}Email:${NC} ${GREEN}${EMAIL}${NC}"
echo -e "${YELLOW}Name:${NC} ${GREEN}${USERNAME}${NC}"
else
exit 0
fi
}
function SET_IDENTITY() {
if [[ "${TEMP}" == "y" ]]; then
echo ""
echo -e "${YELLOW}Setting Git Identity${NC}"
git config --global user.name "${USERNAME}"
git config --global user.email "${EMAIL}"
echo ""
echo -e "${GREEN}Done!${NC}"
else
echo ""
echo -e "${YELLOW}Nothing Changed${NC}"
fi
}
if [[ -z "${GIT_USERNAME}" || -z "${GIT_EMAIL}" ]]; then
echo -e "${YELLOW}Git Identity not found${NC}"
echo ""
echo "Add Git Identity?"
echo "y for yes, anything else to exit"
read -r TEMP
GET_IDENTITY
echo ""
echo "Continue?"
echo "y for yes, anything else to exit"
read -r TEMP
SET_IDENTITY
else
echo -e "${GREEN}Git Identity found${NC}"
echo ""
echo -e "${YELLOW}Email:${NC} ${GREEN}${GIT_EMAIL}${NC}"
echo -e "${YELLOW}Name:${NC} ${GREEN}${GIT_USERNAME}${NC}"
echo ""
echo "Change Git Identity?"
echo "y for yes, anything else to exit"
read -r TEMP
GET_IDENTITY
echo ""
echo "Continue?"
echo "y for yes, anything else to exit"
read -r TEMP
SET_IDENTITY
fi