-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·254 lines (223 loc) · 7.43 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·254 lines (223 loc) · 7.43 KB
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
#!/bin/bash
############################
# install.sh
# This script does all the install steps.
############################
#TODO: spacemacs from nikki93, tmux
dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
if [[ "$OSTYPE" == "darwin"* ]]; then
is_mac=true
is_linux=
elif [[ "$OSTYPE" == "linux-gnu" ]]; then
is_mac=
is_linux=true
else
is_mac=
is_linux=
fi
#-----
# Handle args
# Defaults
arg_programs=
arg_shell=
arg_dotfiles=
arg_git=
print_help() {
echo "--------------------------------------------------------------------------------"
echo "$0 [options]"
echo
echo "This program sets up your environment for you."
echo "You have to provide arguments for what you want it to set up."
echo "By default, it will not install anything."
echo
echo "options:"
echo "-h, --help show brief help"
echo "--all install all below options"
echo "--programs default: no install"
echo "--shell zsh|bash default: no install; if all then zsh"
echo "--dotfiles default: no install"
echo "--git default: no install"
exit 0
}
if [[ "$#" -eq 0 ]]; then
print_help
fi
while test $# -gt 0; do
case "$1" in
-h|--help)
print_help
;;
--all)
arg_shell="zsh"
arg_programs=true
arg_dotfiles=true
arg_git=true
shift
;;
--programs)
arg_programs=true
shift
;;
--shell)
shift
arg_shell="$1"
if [ "$arg_shell" != "zsh" ] && [ "$arg_shell" != "bash" ]; then
echo "Unknown --shell: $arg_shell"
print_help
exit 1
fi
shift
;;
--dotfiles)
arg_dotfiles=true
shift
;;
--git)
arg_git=true
shift
;;
*)
echo "Unknown option or argument: $1"
print_help
exit 1
esac
done
#-----
# program installs
if [ "$arg_programs" = true ]; then
if [ $is_mac = true ]; then
echo "================================================================================"
echo "OS X program installs"
echo "--------------------------------------------------------------------------------"
echo "installing Homebrew"
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
echo -e "done\n"
echo "installing new vim"
# https://coderwall.com/p/j9wnfw/vim-tmux-system-clipboard
brew install macvim --with-override-system-vim && brew linkapps
brew install reattach-to-user-namespace
echo -e "done\n"
# https://robots.thoughtbot.com/tmux-copy-paste-on-os-x-a-better-future
echo "installing tmux"
brew install tmux
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
echo -e "done\n"
echo "installing user-modifiable Python"
# http://stackoverflow.com/a/20691578/1232944
brew install python
brew unlink python && brew link --overwrite python
echo "Here\'s some other stuff you might need:"
echo "IDEs: XCode, Android Studio, Eclipse, PyCharm"
echo "SDKs: Java + Java SDK"
echo "Other: Hammerspoon, Flux"
echo "Press enter to continue..."
read -e
elif [ $is_linux = true ]; then
echo "================================================================================"
echo "Linux program installs"
echo "--------------------------------------------------------------------------------"
sudo apt-get install vim
sudo apt-get install tmux
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
sudo apt-get install zsh
sudo apt-get install xclip
fi
sudo pip install jupyter matplotlib ipdb numpy
# https://github.com/VundleVim/Vundle.vim
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
vim +PluginInstall +qall
fi
#-----
# zsh or bash?
if [ ! -z "$arg_shell" ]; then
echo "================================================================================"
echo "setting up your shell"
echo "--------------------------------------------------------------------------------"
if [ "$arg_shell" == "zsh" ]; then
if [ -f /bin/zsh -o -f /usr/bin/zsh ]; then
echo "using zsh"
echo
if [ ! -d "$HOME/.oh-my-zsh" ]; then
echo "installing oh-my-zsh"
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
echo
else
echo "oh-my-zsh already installed"
echo
ZSH_PATH=`which zsh`
if [ "$SHELL" != "$ZSH_PATH" ]; then
echo "chsh -s $ZSH_PATH"
chsh -s $ZSH_PATH
export SHELL=$ZSH_PATH
else
echo "default shell is already zsh, nothing to do"
echo
fi
fi
echo "cp $dir/dotfiles/.bashrc $HOME/.oh-my-zsh/custom/$USER.zsh"
cp $dir/dotfiles/.bashrc $HOME/.oh-my-zsh/custom/$USER.zsh
else
echo "zsh not available, using bash instead"
arg_shell="bash"
fi
fi
if [ "$arg_shell" == "bash" ]; then
echo "using bash"
echo
BASH_PATH=`which bash`
if [ "$SHELL" != "$BASH_PATH" ]; then
echo "chsh -s $BASH_PATH"
chsh -s $BASH_PATH
export SHELL=$BASH_PATH
else
echo "default shell is already bash, nothing to do"
echo
fi
fi
echo -e "done\n"
fi
#-----
# dotfiles
if [ "$arg_dotfiles" = true ]; then
echo "================================================================================"
echo "installing dotfiles"
echo "--------------------------------------------------------------------------------"
dir_dotfiles=$dir/dotfiles
dir_dotfiles_old=$dir_dotfiles/old
dotfiles="$(ls -A $dir_dotfiles)"
if [ ! -d $dir_dotfiles_old ]; then
echo "mkdir $dir_dotfiles_old"
mkdir $dir_dotfiles_old
echo
fi
for file in $dotfiles; do
if [ "$file" != "old" ]; then
# If existing symlink
if [ -h ~/$file ]; then
echo "rm ~/$file"
rm ~/$file
# If existing regular file
elif [ -e ~/$file ]; then
echo "mv ~/$file $dir_dotfiles_old/"
mv ~/$file $dir_dotfiles_old/
fi
# Now, make the symlink
echo "ln -s $dir_dotfiles/$file ~/$file"
ln -s $dir_dotfiles/$file ~/$file
echo
fi
done
echo -e "done\n"
fi
#-----
# git
if [ "$arg_git" = true ]; then
echo "================================================================================"
echo "setting up git"
echo "--------------------------------------------------------------------------------"
git config --global user.name "Josh Chen"
git config --global user.email "jwayne@users.noreply.github.com"
git config credential.helper cache
git config --global push.default matching
echo -e "done\n"
fi