-
Notifications
You must be signed in to change notification settings - Fork 2
/
install.sh
executable file
·240 lines (192 loc) · 5.65 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
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
#!/bin/bash
if [[ "$0" != "./install.sh" ]]; then
echo "Please run $0 from its own directory."
exit 1
fi
CONFIG_DIR=$PWD
DID_UPDATE_BREW="NO"
USAGE=$(cat <<-END
USAGE: $0 <package>|all
This script bootstraps your shell environment by installing configs,
installers (e.g., brew), and useful programs. The following packages are
supported:
configs only install shell config files
coffeescript install coffeescript language tools
games install command-line game runners
go install go language tools
heroku install the Heroku CLI
node install NodeJS language tools
postgresql install PostgreSQL
python install Python language tools
ruby install Ruby language tools
typescript install TypeScript language tools
webtools install tools for web development
END
)
# Base Functions #######################################################################################################
function __configure_git() {
echo "Setting up Git configuration..."
NAME=$(git config --global user.name)
read -p "Git full name ($NAME): " RESPONSE
[[ "$RESPONSE" == "" ]] || NAME="$RESPONSE"
git config --global user.name "$NAME"
EMAIL=$(git config --global user.email)
read -p "Git email address ($EMAIL): " RESPONSE
[[ "$RESPONSE" == "" ]] || EMAIL="$RESPONSE"
git config --global user.email "$EMAIL"
}
function __install_all() {
__install_configs
__install_brew
__install_basics
__install_gcc
__install_vim
__install_coffeescript
__install_go
__install_heroku
__install_node
__install_python
__install_ruby
__install_typescript
__install_webtools
}
function __install_brew() {
if ! which -s brew; then
echo "Brew is not installed. Installing now..."
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
__update_brew
fi
}
function __install_with() {
INSTALLER="$1"
PACKAGE="$2"
CHECK="$3"
OPTS=""
[[ "$CHECK" == "" ]] && CHECK="$PACKAGE"
if ! which -s "$CHECK"; then
if [[ "$INSTALLER" == "brew" ]]; then
__update_brew
elif [[ "$INSTALLER" == "npm" ]]; then
which -s node || __install_node
OPTS="-g"
elif [[ "$InSTALLER" == "pip" ]]; then
which -s python || __install_python
fi
$INSTALLER install $OPTS $PACKAGE
else
echo "$CHECK was already installed"
fi
}
function __update_brew() {
__install_brew
if [[ "$DID_UPDATE_BREW" == "NO" ]]; then
echo "Updating brew, one moment..."
brew update
fi
DID_UPDATE_BREW="YES"
}
# Package Functions ####################################################################################################
function __install_basics() {
__install_with brew ag
__install_with brew ctags
__install_with brew fswatch
__install_with brew reattach-to-user-namespace
__install_with brew tmux
__install_with brew tmuxinator
__install_with brew watch
__install_with brew wget
}
function __install_coffeescript() {
__install_with npm coffeescript
}
function __install_configs() {
sudo chpass -s /bin/bash $USER
pushd $HOME >/dev/null
echo "Installing standard config files..."
for FILE in $(ls -A "$CONFIG_DIR/home"); do
[[ -e "$FILE" ]] && rm -rf "$FILE"
ln -sf "$CONFIG_DIR/home/$FILE" "$FILE"
done
__configure_git
popd >/dev/null
}
function __install_docker() {
__install_with brew awscli aws
__install_with brew derailed/k9s/k9s k9s
}
function __install_games() {
__install_with brew frobtads
}
function __install_gcc() {
__install_with brew gcc
}
function __install_go() {
__install_with brew go
}
function __install_heroku() {
(brew tap heroku/brew && __install_with brew heroku)
}
function __install_node() {
if [[ ! -e "/usr/local/opt/nvm/nvm.sh" ]]; then
__install_with brew nvm
echo "NVM has been installed, but you need to restart your shell to continue."
echo "Re-run '$0 node' when you have restarted."
exit 1
else
source /usr/local/opt/nvm/nvm.sh
fi
nvm install 12
nvm use 12
__install_with npm nodemon
}
function __install_postgresql() {
__install_with brew postgresql
__install_with brew unixodbc
}
function __install_python() {
__install_with brew pyenv
VERSION="3.10.0"
echo "Installing Python $VERSION"
pyenv install -s "$VERSION"
pyenv global "$VERSION"
pyenv version
pip install --upgrade pip
__install_with pip jedi
__install_with pip poetry
}
function __install_ruby() {
__install_with brew rbenv
}
function __install_webtools() {
__install_node
__install_with npm browserify
__install_with npm eslint
__install_with npm node-sass
__install_with npm pug-cli
}
function __install_typescript() {
__install_node
__install_with npm typescript tsc
__install_with npm tslint
__install_with npm ts-node
__install_with npm tsserver
}
function __install_vim() {
__update_brew
ls -l $(which vim) | grep "Cellar/vim" >/dev/null || __install_with brew vim
vim +PlugClean +PlugInstall +qall
}
########################################################################################################################
DID_RUN="NO"
while [[ "$1" != "" ]]; do
FUNC="__install_$1"
if [[ $(type "$FUNC") == *"function"* ]]; then
DID_RUN="YES"
$FUNC
fi
shift
done
if [[ "$DID_RUN" == "NO" ]]; then
echo "$USAGE"
fi
echo