-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgituser.sh
executable file
·175 lines (151 loc) · 3.44 KB
/
gituser.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/bin/bash
pause()
{
read -s -n 1 -p "Press any key to continue...";
}
quit()
{
clear;
exit;
}
gitverify(){
clear;
printf '\n\n';
echo "Current Username : $(git config --global user.name)";
echo "Current EmailID : $(git config --global user.email)";
printf '\n\n';
pause;
}
gitexecute(){
git config --global --replace-all user.name $name
git config --global --replace-all user.email $email
gitverify;
}
init(){
iofile=~/.sec/seed
if [ -f "$iofile" ]; then
count=$(grep -o -i ::email $iofile | wc -l)
else
count=0;
mkdir -p ~/.sec
fi
}
inputto(){
clear;
while :
do
count=$(($count+1));
printf %s "enter username : ";
read uname;
if [[ "$uname" == ":q" ]];
then
break;
fi;
printf %s "enter emailID : ";
read email;
if [[ "$email" == ":q" ]];
then
break;
fi;
echo "::username$count : $uname">>$iofile
echo "::email$count : $email">>$iofile
printf '\nenter :q to exit\n';
done
}
readfrom(){
if [[ "$count" > 0 ]];
then
for c in `seq 1 $(grep -o -i ::email $iofile | wc -l)`
do
echo " $c - $(grep "::username$c" $iofile | cut -d " " -f3) ($(grep "::email$c" $iofile | cut -d " " -f3)) ";
echo "---------------------------------------------------";
done
fi;
}
editdata(){
clear
if [[ "$count" > 0 ]]; then
readfrom;
echo " b - back";
echo "---------------------------------------------------";
read eval;
if [[ $eval ]] && [ $eval -eq $eval 2>/dev/null ];
then
if [[ "$eval" -gt 0 && "$eval" -le $c ]];
then
clear;
echo "Previous username : $(grep "::username$eval" $iofile | cut -d " " -f3)";
printf %s "new username : ";
read newval;
sed -i "s/$(grep "::username$eval" $iofile | cut -d " " -f3)/$newval/" $iofile
echo "Previous email : $(grep "::email$eval" $iofile | cut -d " " -f3)";
printf %s "new emailID : ";
read newval;
sed -i "s/$(grep "::email$eval" $iofile | cut -d " " -f3)/$newval/" $iofile
fi;
fi;
fi;
}
window()
{
clear
echo "Change Default gitAccount ";
echo "---------------------------------------------------";
readfrom;
echo " d - input data ";
echo "---------------------------------------------------";
if [[ "$count" > 0 ]];
then
echo " e - edit data";
echo "---------------------------------------------------";
fi;
echo " i - info ";
echo "---------------------------------------------------";
echo " c - clear ";
echo "---------------------------------------------------";
echo " q - quit ";
echo "---------------------------------------------------";
printf %s "Enter the option : ";
read val;
if [[ "$val" == "d" || "$val" == "D" ]];
then
inputto;
fi;
if [[ "$val" == "c" || "$val" == "C" ]];
then
rm -rf .sec
fi;
if [[ "$count" > 0 ]];
then
if [[ $val ]] && [ $val -eq $val 2>/dev/null ];
then
echo "pass 1";
if [[ "$val" -gt 0 && "$val" -le $c ]];
then
echo "pass 2";
name=$(grep "::username$val" $iofile | cut -d " " -f3);
email=$(grep "::email$val" $iofile | cut -d " " -f3);
gitexecute;
else
echo "$val $c";
fi;
fi;
if [[ "$val" == "e" || "$val" == "E" ]];
then
editdata;
fi;
fi;
if [[ "$val" == "i" || "$val" == "I" ]];
then
gitverify;
fi;
if [[ "$val" == "q" || "$val" == "Q" ]];
then
quit;
fi;
}
init;
while :
do
window;
done