forked from Bash-it/bash-it
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·98 lines (89 loc) · 2.32 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
#!/usr/bin/env bash
BASH_IT="$HOME/.bash_it"
cp $HOME/.bash_profile $HOME/.bash_profile.bak
echo "Your original .bash_profile has been backed up to .bash_profile.bak"
cp $HOME/.bash_it/template/bash_profile.template.bash $HOME/.bash_profile
echo "Copied the template .bash_profile into ~/.bash_profile, 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 "${src}" "${dest}"
else
echo "File ${dest} exists, skipping"
fi
done
}
function load_some() {
file_type=$1
for path in `ls $BASH_IT/${file_type}/available/[^_]*`
do
if [ ! -d "$BASH_IT/$file_type/enabled" ]
then
mkdir "$BASH_IT/$file_type/enabled"
fi
file_name=$(basename "$path")
while true
do
read -p "Would you like to enable the ${file_name%%.*} $file_type? [Y/N] " RESP
case $RESP in
[yY])
ln -s "$path" "$BASH_IT/$file_type/enabled"
break
;;
[nN])
break
;;
*)
echo "Please choose y or n."
;;
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