-
Notifications
You must be signed in to change notification settings - Fork 38
/
setup.sh
65 lines (57 loc) · 1.43 KB
/
setup.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
#!/usr/bin/env zsh
function Echo_Color(){
case $1 in
r* | R* )
COLOR='\033[0;31m'
;;
g* | G* )
COLOR='\033[0;32m'
;;
y* | Y* )
COLOR='\033[0;33m'
;;
b* | B* )
COLOR='\033[0;34m'
;;
*)
echo "$COLOR Wrong COLOR keyword!\033[0m"
;;
esac
echo -e "$COLOR$2\033[0m"
}
case $SHELL in
*zsh )
profile=~/.zshrc
logout_profile=~/.zlogout
;;
*bash )
profile=~/.bashrc
logout_profile=~/.bash_logout
;;
* )
Echo_Color r "Unknown shell, need to manually add config on your shell profile!!"
profile='unknown'
logout_profile='unknown'
;;
esac
gitacc_config='# git account switch
source $HOME/.git-acc'
cp ./git-acc.sh ~/.git-acc
if [ "$profile" = "unknown" ]; then
echo 'Paste the information down below to your profile:'
Echo_Color y "$gitacc_config\n"
echo 'Paste the information down below to your profile:'
Echo_Color y "$(cat ./logout.script)\n"
else
if [ "$(grep -xn "$gitacc_config" $profile)" != "" ]; then
Echo_Color g "You have already added git-acc config in $profile !!\nOnly update your git-acc!"
else
printf "\n$gitacc_config\n" >> $profile
echo "$(cat ./logout.script)" >> $logout_profile
fi
fi
if ! [ -f ~/.gitacc ]; then
printf "" >> ~/.gitacc
fi
source $profile
echo "Done!! Now can use! Enjoy~~~"