-
Notifications
You must be signed in to change notification settings - Fork 2
/
config_macos.sh
executable file
·264 lines (240 loc) · 5.82 KB
/
config_macos.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
#! /bin/sh
#
# config.sh
# Copyright (C) 2018 Daniel Santiago <dspelaez@gmail>
#
# Distributed under terms of the GNU/GPL license.
#
# ===================================================================
# Setting up OSX for scientific use
# -------------------------------------------------------------------
#
# Usage:
# curl https://raw.githubusercontent.com/dspelaez/dotfiles/master/config.sh -o config.sh
# sh ./config.sh
#
# Author:
# Daniel Santiago
# github/dspelaez
# ===================================================================
# 1. install xcode {{{
# ===============================
install_xcode () {
clear
if [[ "$(xcode-select -p)" == "" ]]; then
printf "\nInstalling Xcode\n"
xcode-select --install
else
printf "\nXcode Installed\n"
fi
}
# --- }}}
# 2. homebrew {{{
# ===============================
install_homebrew () {
clear
if ! command -v brew > /dev/null 2>&1; then
printf "\nInstalling Homebrew\n"
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
else
printf "\nHomebrew Installed\n"
fi
# 3.1. update homebrew
# -------------------------------
printf "\nUpdating Homebrew\n"
brew update
brew update
brew upgrade
# 3.2. install some apps
# -------------------------------
apps=(
wget
git
coreutils
gcc
vim
neovim
tmux
tmuxinator
imagemagick
pandoc
markdown
htop
ffmpeg
node
)
printf "\nThe following formulae will be installed\n"
printf ' - %s\n' "${apps[@]}"
printf "\nContinue [y/n] "; read OK
if [ "$OK" != "Y" ] && [ "$OK" != "y" ]
then
continue
else
for app in "${apps[@]}"; do
brew install ${app}
done
fi
# 3.4. install some casks
# -------------------------------
apps=(
brave-browser
skim
spotify
dropbox
google-backup-and-sync
google-drive-file-stream
docker
iterm2
inkscape
mactex
)
printf "\nThe following casks will be installed\n"
printf ' - %s\n' "${apps[@]}"
printf "\nContinue [y/n] "; read OK
if [ "$OK" != "Y" ] && [ "$OK" != "y" ]
then
printf "\n Exiting installation...\n"
exit 0
else
for app in "${apps[@]}"; do
brew cask install ${app}
done
brew cleanup
fi
}
# --- }}}
# 3. install conda {{{
# ===============================
install_conda () {
# TODO: Better ask for installing miniconda or anaconda
printf "\nInstalling Miniconda? [y/n] "; read OK
if [ "$OK" != "Y" ] && [ "$OK" != "y" ]
then
printf "\n Exiting installation...\n"
exit 0
else
wget -nc -nv https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
bash ./Miniconda3-latest-MacOSX-x86_64.sh -s -b -p $HOME/.miniconda
$HOME/.miniconda/bin/conda update -n base -c default conda
$HOME/.miniconda/bin/conda config --add channels conda-forge
fi
}
# --- }}}
# 4. change default shell by zsh {{{
# ===============================
config_zsh () {
printf "\nInstalling Oh-my-zsh? [y/n] "; read OK
if [ "$OK" != "Y" ] && [ "$OK" != "y" ]
then
printf "\n Exiting installation...\n"
exit 0
else
#
# download oh-my-zsh and spaceship
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
curl -fsSL https://starship.rs/install.sh | bash
#
fi
}
# --- }}}
# 5. copy dotfiles {{{
# ==============================
copy_dotfiles () {
printf "\nAdd dotfiles [y/n] "; read OK
if [ "$OK" != "Y" ] && [ "$OK" != "y" ]
then
printf "\n Exiting installation...\n"
exit 0
else
#
# clone repository and copy files to $HOME
rm -rf $HOME/dotfiles
git clone https://github.com/dspelaez/dotfiles.git
cd dotfiles && cp -r dotfiles $HOME/.dotfiles
#
# make symbolic links
sh ./symlink.sh
cd $HOME
fi
}
# --- }}}
# 6. config neovim and tmux {{{
# ==============================
config_vim () {
printf "\nConfig neovim? [y/n] "; read OK
if [ "$OK" != "Y" ] && [ "$OK" != "y" ]
then
printf "\n Exiting installation...\n"
exit 0
else
#
# create virtual environment including neovim and jedi
# TODO: include flake8 or pylint or something
printf "\nCreating virtual environment for neovim\n";
$HOME/.miniconda/bin/conda create -n neovim python=3.8
$HOME/.miniconda/bin/conda install -c conda-forge -n neovim neovim jedi unidecode
# config neovim and vim
nvim +PlugInstall +PlugUpgrade +PlugUpdate +PlugClean! +UpdateRemotePlugins +qall
vim +PlugInstall +PlugUpgrade +PlugUpdate +PlugClean! +UpdateRemotePlugins +qall
fi
printf "\nConfig tmux & tmuxinator? [y/n] "; read OK
if [ "$OK" != "Y" ] && [ "$OK" != "y" ]
then
printf "\n Exiting installation...\n"
exit 0
else
# config tmux
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
tmux source $HOME/.tmux.conf
fi
}
# --- }}}
# parse the arguments to execute the program
# ===========================================
printf "\nSetting up you OSX\n"
printf "\nConitnue? [y/n] "; read OK
if [ "$OK" != "Y" ] && [ "$OK" != "y" ]
then
printf "\n Exiting installation...\n"
exit 0
else
# create main directory
mkdir -p $HOME/tmp/
cd $HOME/tmp
# parse the argument
arg=$1
# install each part separately
if [ $arg == "xcode" ]; then
install_xcode
#
elif [ $arg == "homebrew" ]; then
install_homebrew
#
elif [ $arg == "conda" ]; then
install_conda
#
elif [ $arg == "zsh" ]; then
config_zsh
#
elif [ $arg == "dotfiles" ]; then
copy_dotfiles
#
elif [ $arg == "vim" ]; then
config_vim
#
elif [ $# -eq 0 ]; then
install_xcode
install_homebrew
install_conda
config_zsh
copy_dotfiles
config_vim
#
else
printf "\n Invalid argument. Exiting installation...\n"
exit 0
#
fi
fi
# cd ../ && rm -rf tmp
# --- end of file ---