forked from ddrexl/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbootstrap
executable file
·240 lines (208 loc) · 7.39 KB
/
bootstrap
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
#!/bin/bash
function exists() {
command -v "${1}" >/dev/null 2>&1
}
function is_installed() {
dpkg-query -W -f='${Status}' "${1}" | grep 'ok installed' > /dev/null
}
function ensure_fzf() {
# Install a fuzzy file finder for the command line (https://github.com/junegunn/fzf)
fzf_install_dir=~/.fzf
if exists fzf; then
echo 'Updating fzf'
fzf_install_dir="$(dirname "$(dirname "$(which fzf)")")"
git -C "${fzf_install_dir}" pull -q
"${fzf_install_dir}"/install --bin > /dev/null
else
echo 'Installing fzf'
if [ -e "${fzf_install_dir}" ]; then rm -rf "${fzf_install_dir}"; fi
git clone --depth 1 https://github.com/junegunn/fzf.git "${fzf_install_dir}" -q
"${fzf_install_dir}"/install --update-rc --key-bindings --completion --no-bash > /dev/null
fi
}
function ensure_oh_my_zsh() {
export ZSH=$HOME/.oh-my-zsh
if [ ! -e "$ZSH" ]; then
echo 'Install OhMyZsh'
# Install my customized oh-my-zsh version
sh -c "$(curl -fsSL https://raw.githubusercontent.com/FaBrand/oh-my-zsh/master/tools/install.sh)"
chsh -s /bin/zsh
else
echo 'OhMyZsh already installed - updating'
sh -c "$(curl -fsSL https://raw.githubusercontent.com/FaBrand/oh-my-zsh/master/tools/upgrade.sh)"
fi
}
function ensure_powerline_fonts() {
echo 'Install powerline fonts'
local POWERLINE_URL='https://github.com/powerline/powerline/raw/develop/font'
local POWERLINE_SYMBOLS_FILE='PowerlineSymbols.otf'
local POWERLINE_SYMBOLS_CONF='10-powerline-symbols.conf'
if [ ! -e ~/.fonts/$POWERLINE_SYMBOLS_FILE ]; then
curl -fsSL $POWERLINE_URL/$POWERLINE_SYMBOLS_FILE -o /tmp/$POWERLINE_SYMBOLS_FILE
mkdir ~/.fonts 2> /dev/null
mv /tmp/$POWERLINE_SYMBOLS_FILE ~/.fonts/$POWERLINE_SYMBOLS_FILE
fc-cache -vf ~/.fonts/
fi
if [ ! -e ~/.config/fontconfig/conf.d/$POWERLINE_SYMBOLS_CONF ]; then
curl -fsSL $POWERLINE_URL/$POWERLINE_SYMBOLS_CONF -o /tmp/$POWERLINE_SYMBOLS_CONF
mkdir -p ~/.config/fontconfig/conf.d 2> /dev/null
mv /tmp/$POWERLINE_SYMBOLS_CONF ~/.config/fontconfig/conf.d/$POWERLINE_SYMBOLS_CONF
fi
}
function ensure_solarized_color_scheme() {
local SOLARIZED_INSTALL_DIR=~/.solarized
if ! exists dconf; then
echo 'Package dconf-cli required for solarized colors!'
return 1
elif [ ! -d $SOLARIZED_INSTALL_DIR ]; then
bash -c 'read -p "Have you already defined a new profile in your Terminal preferences e.g. '"'SolDark'"' If not add it now and continue by pressing the return key..."'
echo Install solarized color scheme
git clone https://github.com/Anthony25/gnome-terminal-colors-solarized.git $SOLARIZED_INSTALL_DIR -q
$SOLARIZED_INSTALL_DIR/install.sh --install-dircolors
else
echo 'Solarized theme already installed'
fi
}
function ensure_dotfiles() {
# never overwrite existing .vimrc.local
if [ ! -f ~/.vimrc.local ]; then
cp .vimrc.local ~/.vimrc.local
fi
echo "Do you want to copy the dotfiles to your home reposory?"
echo "(This may overwrite some files) Are you sure? (y/[n]) ";
read -rn reply
if [[ ${reply} =~ ^[YyZz]$ ]]; then
rsync --exclude '.git/' \
--exclude 'bootstrap' \
--exclude '.vimrc.local' \
--exclude 'README.md' \
--exclude 'catkin_aliases/*' \
--exclude 'dircolors' \
-avh --no-perms . ~;
fi
}
function _patch_git_config() {
echo 'Patch gitconfig to include the Settings'
touch ~/.gitconfig
if ! grep 'path = ~/.git_settings' ~/.gitconfig > /dev/null ; then
echo "[include]" >> ~/.gitconfig
echo " path = ~/.git_settings" >> ~/.gitconfig
fi
}
function _patch_zshrc() {
echo 'Set Theme to bira'
sed -i 's/^ZSH_THEME.*/ZSH_THEME="bira"/' ~/.zshrc
}
function patch_dotfiles() {
_patch_zshrc
_patch_git_config
}
function ensure_vim_configuration() {
# Check vim installation and perform changes if necessary
if is_installed vim-tiny; then
echo 'Removing vim-tiny installation'
sudo apt-get -qq remove vim-tiny
fi
if is_installed vim-gnome; then
echo 'vim gnome already installed. Updating vim'
sudo apt-get update -qq
sudo apt-get install --only-upgrade -qq -y vim-gnome
else
echo 'Installing vim (huge config)'
sudo apt-get install -qq vim-gnome
fi
vim +PlugInstall +PlugUpdate +PlugUpgrade +qall
}
function ensure_buildifier() {
echo "Downloading buildifier"
install_path=/opt/buildifier/buildifier
sudo rm -rf "$(dirname ${install_path})" 2> /dev/null
sudo mkdir -p "$(dirname ${install_path})"
#Downloading
curl -fsSL "https://api.github.com/repos/bazelbuild/buildtools/releases/latest" | jq '.assets[] | select( .name == "buildifier" ) | .browser_download_url' | xargs sudo curl -fsSL -o $install_path
sudo chmod +x $install_path
#Make it visible
symlink=/usr/local/bin/buildifier
[ ! -e $symlink ] && sudo ln -s $install_path $symlink
}
function ensure_buildozer() {
echo "Downloading buildozer"
install_path=/opt/buildozer/buildozer
sudo rm -rf "$(dirname ${install_path})" 2> /dev/null
sudo mkdir -p "$(dirname ${install_path})"
#Downloading
curl -fsSL "https://api.github.com/repos/bazelbuild/buildtools/releases/latest" | jq '.assets[] | select( .name == "buildozer" ) | .browser_download_url' | xargs sudo curl -fsSL -o $install_path
sudo chmod +x $install_path
#Make it visible
symlink=/usr/local/bin/buildozer
[ ! -e $symlink ] && sudo ln -s $install_path $symlink
}
function ensure_bazelisk() {
if is_installed bazel; then
echo 'Removing bazel installation'
sudo apt-get -qq remove bazel
fi
echo "Downloading bazelisk"
install_path=/opt/bazelisk/bazelisk
sudo rm -rf "$(dirname ${install_path})" 2> /dev/null
sudo mkdir -p "$(dirname ${install_path})"
#Downloading
curl -fsSL "https://api.github.com/repos/bazelbuild/bazelisk/releases/latest" | jq '.assets[] | select( .name == "bazelisk-linux-amd64" ) | .browser_download_url' | xargs sudo curl -fsSL -o $install_path
sudo chmod +x $install_path
#Make it visible
symlink=/usr/local/bin/bazelisk
[ ! -e $symlink ] && sudo ln -s $install_path $symlink
bazelisk_symlink=/usr/local/bin/bazel
[ ! -e $bazelisk_symlink ] && sudo ln -s $symlink $bazelisk_symlink
}
function ensure_packages() {
# Install usefull packages
packages=(
build-essential
clang-format
clang-tidy
cmake
cppcheck
curl
dconf-cli
entr
exuberant-ctags
git
htop
jq
meld
nmon
python-autopep8
python-dev
python-yapf
python3-dev
rsync
shellcheck
silversearcher-ag
taskwarrior
tmux
tmuxinator
tree
valgrind
xsel
yamllint
zsh
)
echo 'Performing apt-get update'
sudo apt-get -qq update
echo "Installing items"
echo "${packages[*]}" | xargs sudo apt install --assume-yes
}
function install_full() {
ensure_packages
ensure_powerline_fonts
ensure_solarized_color_scheme
ensure_oh_my_zsh
ensure_dotfiles
patch_dotfiles
ensure_fzf
ensure_vim_configuration
ensure_buildifier
ensure_buildozer
ensure_bazelisk
}