-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.sh
executable file
·122 lines (108 loc) · 2.93 KB
/
install.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
#!/bin/sh
echo ""
echo " _ _ __ _ _ "
echo " __| | ___ | |_ / _(_) | ___ ___ "
echo " / _ |/ _ \| __| |_| | |/ _ \/ __| "
echo " | (_| | (_) | |_| _| | | __/\__ \ "
echo " (_)__,_|\___/ \__|_| |_|_|\___||___/ "
echo "======--------------------------------------------------======"
function pick {
choice=0
menu=$@
tail=`expr ${#menu[@]} - 1`
printf "\e[32mChoose one\e[m\n" >&2
for _ in $(seq 0 $tail);do echo "" >&2;done
while true; do
printf "\e[${#menu[@]}A\e[m" >&2
for i in $(seq 0 $tail);do
if [ $choice = $i ]
then
printf "\e[1;31m>\e[m \e[1;4m" >&2
else
printf " " >&2
fi
printf "${menu[$i]}\e[m\n" >&2
done
read -sn1 answer
if [ "$answer" = "^[" ]; then
read -sn2 answer
fi
case $answer in
"j"|"[B")
if [ $choice -lt $tail ]; then choice=`expr $choice + 1`; fi
;;
"k"|"[A")
if [ $choice -gt 0 ]; then choice=`expr $choice - 1`; fi
;;
"")
echo $choice
return
;;
esac
done
}
# download and move to repo
function checkin {
if [ -z $MDOTDIR ]; then
# cloning repo
git clone --depth 1 https://github.com/matsub/dotfiles.git
echo dotfiles
else
# update dotfiles
echo $MDOTDIR
fi
}
echo " LICENSE: MIT License Copyright (c) 2018 matsub "
echo " Author: matsub <matsub.rk@gmail.com> "
echo "======--------------------------------------------------======"
echo " Repository: https://github.com/matsub/dotfiles "
echo ""
# make a choice
menu=(
"1) Install dotfiles only"
"2) Install dotfiles and its plugin manager"
"3) Install all environments (This will install all applications I use)"
"4) Remove this dotfiles"
"5) Cancel"
)
# get the location of dotfiles dir
repo=`checkin`
echo ""
pushd $repo > /dev/null
choice=`pick $menu`
echo ""
case $choice in
0) # Install dotfiles only
make dotfiles
;;
1) # Install dotfiles and its plugin manager
make environment
;;
2) # Install all environments
make all
;;
3) # Remove this dotfiles
make clean
popd > /dev/null
exit
;;
4) # Cancel
popd > /dev/null
rm -rf $repo
exit
;;
esac
# completed!
# change login shell
echo ""
printf "\e[1m"
echo " Install completed!"
echo "===================="
printf "\e[m"
echo "please change login shell with:"
echo " chsh -s /bin/zsh"
echo "or add /usr/local/bin/fish to /etc/shells and:"
echo " chsh -s /usr/local/bin/fish"
echo ""
# back to initial path
popd > /dev/null