forked from Bash-it/bash-it
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·104 lines (95 loc) · 2.47 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
#!/usr/bin/env bash
BASH_IT="$HOME/.bash_it"
case $OSTYPE in
darwin*)
CONFIG_FILE=.bash_profile
;;
*)
CONFIG_FILE=.bashrc
;;
esac
test -w $HOME/$CONFIG_FILE &&
cp $HOME/$CONFIG_FILE $HOME/$CONFIG_FILE.bak &&
echo "Your original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak"
cp $HOME/.bash_it/template/bash_profile.template.bash $HOME/$CONFIG_FILE
echo "Copied the template $CONFIG_FILE into ~/$CONFIG_FILE, edit this file to customize bash-it"
while true
do
read -p "Do you use Jekyll? (If you don't know what Jekyll is, answer 'n') [Y/N] " RESP
case $RESP in
[yY])
cp $HOME/.bash_it/template/jekyllconfig.template.bash $HOME/.jekyllconfig
echo "Copied the template .jekyllconfig into your home directory. Edit this file to customize bash-it for using the Jekyll plugins"
break
;;
[nN])
break
;;
*)
echo "Please enter Y or N"
esac
done
function load_all() {
file_type=$1
[ ! -d "$BASH_IT/$file_type/enabled" ] && mkdir "$BASH_IT/${file_type}/enabled"
for src in $BASH_IT/${file_type}/available/*; do
filename="$(basename ${src})"
[ ${filename:0:1} = "_" ] && continue
dest="${BASH_IT}/${file_type}/enabled/${filename}"
if [ ! -e "${dest}" ]; then
ln -s "../available/${filename}" "${dest}"
else
echo "File ${dest} exists, skipping"
fi
done
}
function load_some() {
file_type=$1
[ -d "$BASH_IT/$file_type/enabled" ] || mkdir "$BASH_IT/$file_type/enabled"
for path in `ls $BASH_IT/${file_type}/available/[^_]*`
do
file_name=$(basename "$path")
while true; do
read -s -n 1 -p "Would you like to enable the ${file_name%%.*} $file_type? [y/N] " RESP
case $RESP in
[yY])
echo "Y"
ln -s "../available/${file_name}" "$BASH_IT/$file_type/enabled"
break
;;
[nN]|"")
echo "N"
break
;;
*)
echo -e "\033[91mPlease choose y or n.\033[m"
;;
esac
done
done
}
for type in "aliases" "plugins" "completion"
do
while true
do
read -p "Would you like to enable all, some, or no $type? Some of these may make bash slower to start up (especially completion). (all/some/none) " RESP
case $RESP
in
some)
load_some $type
break
;;
all)
load_all $type
break
;;
none)
break
;;
*)
echo "Unknown choice. Please enter some, all, or none"
continue
;;
esac
done
done