-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·301 lines (248 loc) · 8.85 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
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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
#!/bin/sh
# Author: Nicolas Cuervo
# Based on install files from thoughtbot and a diversity of contributers
set -e
#Using formatting for print statements. For this I use the ANSI escape codes.
#you can choose different formatting of choice.
#Black 0;30 Dark Gray 1;30
#Red 0;31 Light Red 1;31
#Green 0;32 Light Green 1;32
#Brown/Orange 0;33 Yellow 1;33
#Blue 0;34 Light Blue 1;34
#Purple 0;35 Light Purple 1;35
#Cyan 0;36 Light Cyan 1;36
#Light Gray 0;37 White 1;37
#Bold 1m Underline 4m
#Blink 5m Revers color 7m
#Dim 2m Hidden 8m
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
BOLD='\033[1m'
GREEN='\033[0;32m'
END='\033[0m'
fancy_echo(){
printf "${BLUE}${BOLD}\n%b\n${END}" "$1"
}
warning_echo(){
printf "${YELLOW}\n%b\n${END}" "$1"
}
done_echo(){
printf "${GREEN}${BOLD}\n%b\n${END}" "$1"
}
# Checks if the file exists. If yes, deletes it
delete_files(){
if [ -f "$1" ]; then
warning_echo "Removing $1"
rm "$1"
fi
}
inst(){
if [ -f /etc/lsb-release ]; then
sudo aptitude install -y "$1"
elif [ -f /etc/redhat-release ]; then
sudo dnf install -y "$1"
else
warning_echo "Your OS distribution is not yet supported by this script"
fi
}
fedora_warning(){
if [ -f /etc/redhat-release ]; then
warning_echo "$1"
fi
}
create_dir(){
if [ ! -d "$1" ]; then
mkdir -p "$1"
fi
}
fancy_echo "Updating system packages ..."
if command -v aptitude >/dev/null; then
fancy_echo "Using aptitude ..."
else
if [ -f /etc/lsb-release ]; then
warning_echo "Ubuntu detected!"
warning_echo "Installing aptitude ..."
sudo apt-get install -y aptitude
sudo aptitude -y update
fancy_echo "Installing basic dependencies needed further in the process..."
inst build-essential
inst libcppunit-dev
inst libcppunit-doc
inst python-requests
inst python-dev
inst python-apt
inst python3-pyqt4
inst python3-tk
inst exuberant-ctags
inst shellcheck
elif [ -f /etc/redhat-release ]; then
warning_echo "Fedora Detected! Using dnf ..."
sudo dnf -y update
fancy_echo "Installing basic dependencies needed further in the process..."
inst python-devel
inst python3-PyQt4
inst cppunit-devel
inst gcc-c++
inst ctags
inst ShellCheck
inst util-linux-user
fi
fi
fancy_echo "Installing python-lxml"
inst python-lxml
fancy_echo "Installing cpufrequtils ..."
inst cpufrequtils
fancy_echo "Installing git ..."
inst git
fancy_echo "Installing gitk ..."
inst gitk
fancy_echo "Installing vim ..."
inst vim
fancy_echo "Installing curl ..."
inst curl
fancy_echo "Installing zsh ..."
inst zsh
fancy_echo "Installing meld ..."
inst meld
fancy_echo "Installing gdb ..."
inst gdb
fancy_echo "Installing htop ..."
inst htop
fancy_echo "Installing cmake ..."
inst cmake
fancy_echo "Installing bpython ..."
inst bpython
fancy_echo "Installing shutter ..."
fedora_warning "This application is known not to work well in Fedora. It will be installed anyways..."
inst shutter
fancy_echo "Setting up custom vim configuration ..."
if [ -d ~/.vim ]; then
warning_echo ".vim found! Creating backup file."
if [ -d ~/.vim.bak ]; then
rm -rf ~/.vim.bak
fi
mv ~/.vim ~/.vim.bak
fi
if [ -h ~/.vimrc ]; then
warning_echo ".vimrc found! Creating backup file."
if [ -h ~/.vimrc.bak ]; then
rm ~/.vimrc.bak
fi
mv ~/.vimrc ~/.vimrc.bak
fi
git clone https://github.com/primercuervo/vimfiles ~/.vim
ln -s ~/.vim/vimrc ~/.vimrc
sh ~/.vim/install.sh
fancy_echo "Creating vim working directories..."
create_dir ~/.backup
create_dir ~/.swp
create_dir ~/.undo
fancy_echo "Retrieving external fonts for Airline..."
wget https://github.com/powerline/powerline/raw/develop/font/PowerlineSymbols.otf
wget https://github.com/powerline/powerline/raw/develop/font/10-powerline-symbols.conf
create_dir ~/.config/fontconfig/conf.d/
create_dir ~/.fonts/
mv PowerlineSymbols.otf ~/.fonts/
mv 10-powerline-symbols.conf ~/.config/fontconfig/conf.d/
fancy_echo "Installing Adobe-fonts needed for Powerline9k..."
if [ ! -d ~/.fonts/adobe-fonts/source-code-pro ]; then
git clone --depth 1 --branch release https://github.com/adobe-fonts/source-code-pro.git ~/.fonts/adobe-fonts/source-code-pro
fi
fc-cache -f -v ~/.fonts/adobe-fonts/source-code-pro
fancy_echo "Installing tmux ..."
inst tmux
fancy_echo "Swapping ESC and Capslock ..."
dconf write /org/gnome/desktop/input-sources/xkb-options "['caps:swapescape']"
silver_searcher_from_source() {
git clone git://github.com/ggreer/the_silver_searcher.git /tmp/the_silver_searcher
inst automake pkg-config libpcre3-dev zlib1g-dev liblzma-dev
sh /tmp/the_silver_searcher/build.sh
cd /tmp/the_silver_searcher
sh build.sh
sudo make install
cd
rm -rf /tmp/the_silver_searcher
}
fancy_echo "Installing The Silver Searcher ..."
if [ -f /etc/lsb-release ]; then
if aptitude show silversearcher-ag &>/dev/null; then
sudo aptitude install -y silversearcher-ag
else
silver_searcher_from_source
fi
elif [ -f /etc/redhat-release ]; then
sudo dnf install -y the_silver_searcher
fi
fancy_echo "Installing oh my zsh..."
sh -c "$(curl -fsSL https://raw.githubusercontent.com/primercuervo/oh-my-zsh/master/tools/install.sh)"
fancy_echo "Installing Powerline9k for Oh-My-ZSH..."
if [ ! -d ~/.oh-my-zsh/custom/themes/powerlevel9k ]; then
git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k
fi
fancy_echo "Installing pip..."
inst python-pip python-dev build-essential
fancy_echo "Installing pip..."
inst python3-pip
fancy_echo "Updating setuptools ..."
sudo pip install --upgrade setuptools
fancy_echo "Installing pylint ..."
sudo pip install --upgrade pylint
fancy_echo "Installing pylint3 ..."
sudo pip3 install --upgrade pylint
fancy_echo "Installing Awesome Terminal fonts for Powerlevel9k..."
if [ ! -d ~/.awesome_fonts ]; then
git clone https://github.com/gabrielelana/awesome-terminal-fonts.git ~/.awesome_fonts
fi
cp ~/.awesome_fonts/build/* ~/.fonts
fc-cache -fv ~/.fonts
cp ~/.awesome_fonts/config/10-symbols.conf ~/.config/fontconfig/conf.d/
fancy_echo "Installing dotfiles..."
fancy_echo "Checking current dotfile directory..."
DOTFILES_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Update dotfiles itself first
fancy_echo "Updating dotfiles from git..."
[ -d "$DOTFILES_DIR/.git" ] && git --work-tree="$DOTFILES_DIR" --git-dir="$DOTFILES_DIR/.git" pull origin master
fancy_echo "Backing up current dotfiles, if any..."
delete_files ~/.bashrc
delete_files ~/.gitconfig
delete_files ~/.gitignore_global
delete_files ~/.zshrc
delete_files ~/.alias
delete_files ~/.pylintrc
fancy_echo "Generating symbolic links..."
ln -sfv "$DOTFILES_DIR/git/gitconfig" ~/.gitconfig
ln -sfv "$DOTFILES_DIR/git/gitignore_global" ~/.gitignore_global
ln -sfv "$DOTFILES_DIR/home/bashrc" ~/.bashrc
ln -sfv "$DOTFILES_DIR/home/zshrc" ~/.zshrc
ln -sfv "$DOTFILES_DIR/home/tmux.conf" ~/.tmux.conf
ln -sfv "$DOTFILES_DIR/system/alias" ~/.alias
ln -sfv "$DOTFILES_DIR/system/pylintrc" ~/.pylintrc
fancy_echo "Changing main shell to zsh ..."
chsh -s "$(which zsh)"
fedora_warning "Bpython seems to complain about integer import,
and that has to do with requests. In order to solve that, uninstall pip
requests with pip and install again with RPM
sudo pip uninstall requests
sudo dnf install -y python2-requests"
fancy_echo "Installing clang-6 for YCM ..."
sudo apt-get remove libclang*
inst clang-6.0
inst clant-format-6.0
sudo update-alternatives --remove-all clang
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-6.0 90 --slave /usr/bin/clang++ clang++ /usr/bin/gclang++-6.0
sudo update-alternatives --remove-all clang-format
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-6.0 90
fancy_echo "Updating gcc to a newer version..."
# http://tuxamito.com/wiki/index.php/Installing_newer_GCC_versions_in_Ubuntu
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt-get update
inst gcc g++ gcc-5 g++-5 gcc-6 g++-6 gcc-7 g++-7
sudo update-alternatives --remove-all gcc
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 90 --slave /usr/bin/g++ g++ /usr/bin/g++-5
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 80 --slave /usr/bin/g++ g++ /usr/bin/g++-6
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70 --slave /usr/bin/g++ g++ /usr/bin/g++-7
sudo update-alternatives --set gcc /usr/bin/gcc-7
fancy_echo "Setting up clang completer for you-complete-me"
~/.vim/bundle/YouCompleteMe/install.py --clang-completer --system-libclang
unset BLUE BOLD YELLOW DOTFILES_DIR
done_echo "Done!"