forked from alejandro-isaza/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.sh
executable file
·157 lines (138 loc) · 3.14 KB
/
bootstrap.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
#!/usr/bin/env bash
#
# This script sets up a new machine with the basics (Homebrew, rbenv, zsh, etc.)
#
user () {
printf "\r [ \033[0;33m?\033[0m ] $1 "
}
check_requirements() {
if [ "$(uname)" == "Darwin" ] && ! hash ruby 2>/dev/null; then
echo 'Please intall ruby'
exit 1
fi
if ! hash git 2>/dev/null; then
echo 'Please intall git'
exit 1
fi
if ! hash zsh 2>/dev/null; then
echo 'Please intall zsh'
exit 1
fi
}
install_homebrew() {
echo ''
echo 'Installing Homebrew...'
if hash brew 2>/dev/null ; then
brew update
else
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" || true
brew doctor
fi
}
install_rbenv_brew() {
echo ''
echo 'Installing rbenv...'
brew install rbenv ruby-build
}
install_rbenv_git() {
echo ''
echo 'Installing rbenv...'
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
export PATH=$HOME/.rbenv/bin:$PATH
}
install_ruby() {
echo ''
echo 'Installing ruby...'
rbenv install --list
echo 'What version of ruby do you want?'
read -e ruby_version
rbenv install $ruby_version || true
rbenv global $ruby_version
}
install_vundle() {
echo ''
echo 'Installing vundle...'
if [ ! -d "~/.vim/bundle/Vundle.vim" ]
then
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
vim +PluginInstall +qall
fi
}
install_tmux() {
echo ''
echo 'Installing tmux and TPM'
if [ "$(uname)" == "Darwin" ]; then
brew install tmux
fi
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
}
install_oh_my_zsh() {
echo ''
echo 'Installing oh my zsh...'
curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh
}
install_utilities() {
echo ''
echo 'Installing delta exa bat...'
if [ "$(uname)" == "Darwin" ]; then
brew install git-delta exa bat
fi
}
install_syntax() {
echo ''
echo 'Installing zsh-syntax-highlighting'
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting
}
install_autosuggestions() {
echo ''
echo 'Installing zsh-autosuggestions'
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
}
setup_zsh() {
if [ "$SHELL" != "/bin/zsh" ]
then
echo ''
echo 'Changing default shell to zsh...'
chsh -s /bin/zsh
fi
}
check_requirements
# Ask whether to install ruby
ruby=true
user "Install rbenv and ruby? [Y/n]?"
read -n 1 action
case "$action" in
n )
ruby=false;;
N )
ruby=false;;
* )
;;
esac
if [ "$(uname)" == "Darwin" ]; then
# Mac OS X
install_homebrew
if [ "$ruby" == "true" ]; then
install_rbenv_brew
fi
brew install fzf
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
# Linux
if [ "$ruby" == "true" ]; then
install_rbenv_git
fi
fi
if [ "$ruby" == "true" ]; then
install_ruby
fi
install_vundle
install_tmux
install_oh_my_zsh
install_utilities
install_autosuggestions
install_syntax
setup_zsh
echo ''
echo 'System ready! Now run install.sh'
exit 0