-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·282 lines (224 loc) · 5.61 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
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
#!/usr/bin/env bash
# This script attempts to set up a clean environment based on my configuration,
# on a Mac system.
#
# THIS SCRIPT IS NOT DESIGNED TO RUN WITHOUT USER INPUT! In particular, the
# generation of the SSH keys will ask for user interaction.
scriptpath="$(cd "$(dirname "$0")"; pwd -P)"
USER="$(whoami)"
source 'helpers.sh'
# Install Command Line Tools & Homebrew ########################################
install-base() {
'xcode-select' --install
if ! command -v brew > /dev/null 2>&1; then
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
login_shell="$(which bash)"
if [ "$SHELL" != "$login_shell" ]; then
grep "$login_shell" /etc/shells >/dev/null || \
sudo bash -c 'echo "'"$login_shell"'" >> /etc/shells'
chsh -s "$login_shell"
fi
}
# Install elementary applications ##############################################
install-homebrew() {
brew update
brew install bash
brew install bash-completion2
brew install git
brew install apparix
brew install gcc
brew install python
brew install v8
brew install node --with-full-icu
brew install ruby
brew install pandoc
brew install zmq
brew install ack
brew install tree
brew install ghostscript --with-x11
brew install imagemagick --with-ghostscript --with-jp2 --with-librsvg --with-libwmf --with-webp --with-x11 --with-openmp
brew install gist
brew tap neovim/neovim
brew install neovim --with-release
}
install-homebrew-cask() {
brew tap caskroom/cask
brew cask update
brew cask install iterm2
brew cask install quicksilver
brew cask install r
brew cask install xquartz
brew cask install google-chrome
brew cask install google-drive
brew cask install basictex
brew cask install latexit
brew cask install dropbox
brew cask install skype
brew cask install rstudio
}
# Install pip packages #########################################################
install-pip() {
pip install --upgrade pip
pip install ipython[all]
pip install grip
}
# Install gems #################################################################
install-gem() {
gem install bundler
}
# Install npm packages #########################################################
install-npm() {
pass
}
# Set up applications ##########################################################
# Set up Neovim
install-vim() {
pip install neovim
# Ensure directories exists
mkdir -p ~/.config
mkdir -p ~/.vim
# Symlink Neovim configuration
[ -e ~/.config/nvim ] || ln -s ~/.vim ~/.config/nvim
[ -e ~/.config/nvim/init.vim ] || ln -s ~/.vimrc ~/.config/nvim/init.vim
}
# Clone personal settings #####################################################
clone-and-deploy-dotfiles() {
pushd ~
git clone https://github.com/klmr/.files.git
cd .files
tee local.conf <<-CONFIG > /dev/null
core
aliases
apparix
inputrc
git
c
r
tmux
vim
CONFIG
./deploy <<< y
popd
}
install-dotfiles() {
[ -d ~/.files ] || clone-and-deploy-dotfiles
}
# Generate an SSH key ##########################################################
install-ssh-keys() {
[ -e ~/.ssh/id_rsa ] || ssh-keygen
}
# Install R packages and modules ###############################################
r_packages=(
devtools
Rcpp
hadley/devtools
smbache/magrittr
hadley/lazyeval
hadley/dplyr
hadley/tidyr
hadley/testthat
klutometis/roxygen
hadley/ggplot2
yihui/knitr
rstudio/rmarkdown
shiny
hadley/readr
hadley/readxl
dgrtwo/broom
rstudio/bookdown
klmr/modules
setwidth
jalvesaq/colorout
hadley/pryr
daattali/ezknitr
httr
optparse
rstudio/packrat
)
r_modules=(
klmr/sys
klmr/decorator
ebi-predocs/ebits
)
r_bioc=(
biomaRt
Biostrings
DESeq2
)
install-r-packages() {
# Ensure package path exists because R insists on an existing path.
# And since R doesn’t set it properly we need to grep for it rather than
# getting it via `Rscript -e '.libPaths()[1]'`.
q_pattern=['"'"'"]
r_lib_path_pattern="\.libPaths(${q_pattern}\(.*\)${q_pattern})"
r_lib_path="$(grep "$r_lib_path_pattern" .Rprofile | sed "s/$r_lib_path_pattern/\1/")"
r_lib_path="${r_lib_path/#\~/$HOME}"
mkdir -p $r_lib_path
install-r packages "${r_packages[@]}"
install-r modules "${r_modules[@]}"
install-r bioc "${r_bioc[@]}"
}
# Install LaTeX packages #######################################################
tlmgr() {
command tlmgr $@ 2> /dev/null
}
install-tex() {
texlive_path="$(cd "$(kpsewhich -var-value TEXMFMAIN)/../../"; pwd -P)"
[ "$(stat -f '%Su' "$texlive_path")" == "$USER" ] || \
sudo chown -R "$USER" "$texlive_path"
tlmgr update --self
tlmgr install latexmk
tlmgr install titlesec
tlmgr install enumitem
}
# Install convenience scripts ##################################################
curl-install() {
local source="$1"
local target="bin/$(basename "$source")"
if [ -x "$target" ]; then
return
fi
curl --progress-bar "$source" -o "$target" && chmod +x "$target"
}
install-scripts() {
mkdir -p bin
curl-install 'https://raw.githubusercontent.com/gnachman/iTerm2/master/tests/imgcat'
}
# Load the different installation modules ######################################
for module in modules/*; do
if [ -f "$module" ]; then
source "$module"
fi
done
# Run installation modules #####################################################
modules=(
base
homebrew
homebrew-cask
pip
gem
npm
vim
dotfiles
ssh-keys
r-packages
tex
)
if [ "$*" != "" ]; then
for module in "$@"; do
if ! array-contains "$module" "${modules[@]}"; then
echo >&2 "Invalid module '$module'"
exit 1
fi
done
modules=("$@")
fi
# Ensure we’re in the home directory.
cd ~
for module in "${modules[@]}"; do
echo "Performing installation for $module"
install-$module
echo
done
# vim: noexpandtab