-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall
More file actions
executable file
·319 lines (255 loc) · 8.15 KB
/
install
File metadata and controls
executable file
·319 lines (255 loc) · 8.15 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
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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
#!/usr/bin/env bash
set -euo pipefail
here="$(dirname "$0")"
here="$(cd "$here"; pwd)"
mkdir -p "${XDG_CONFIG_HOME:=$HOME/.config}"
install_submodules() {
echo "Installing submodules"
git submodule init
git submodule update
}
install_basic_packages() {
echo "Download package lists"
sudo apt-get update -q -y >/dev/null
echo "Install basic tools"
sudo apt install -y \
ack-grep \
aspell \
aspell-en \
bat \
btop \
build-essential \
cargo \
default-libmysqlclient-dev \
deja-dup \
dnsutils \
fish \
fonts-inconsolata \
foot \
git \
golang-go \
htop \
httpie \
kakoune \
laptop-mode-tools \
libmagickwand-dev \
libreadline-dev \
libssl-dev \
libyaml-dev \
mailutils \
mailutils-pop3d \
make \
ncal \
ncdu \
opensnitch \
thunderbird \
tidy \
tmux \
tree \
vlc \
wget \
zlib1g-dev \
>/dev/null
}
remove_unnecessary_packages() {
echo "Remove unnecessary packages"
sudo apt remove -y --purge evolution speech-dispatcher > /dev/null
sudo apt autoremove -y > /dev/null
}
install_local_bin() {
mkdir -p "${HOME}/.local/bin"
for file in "${here}/bin"/*; do
name="$(basename "$file")"
ln -sfv "$file" "${HOME}/.local/bin/${name}"
done
}
link_dotfiles() {
echo "Link dotfiles"
dotfiles=(gitattributes rdebugrc rspec tmux.conf)
for file in "${dotfiles[@]}"; do
dotname=".${file}"
ln -sfv "${here}/${file}" "${HOME}/${dotname}"
done
}
setup_git() {
# Core configurations
git config --global core.editor "vim"
git config --global core.excludesFile "~/.gitignore"
# Color configurations
git config --global color.ui "auto"
git config --global color.branch.current "yellow reverse"
git config --global color.branch.local "yellow"
git config --global color.branch.remote "green"
git config --global color.diff.meta "yellow bold"
git config --global color.diff.frag "magenta bold"
git config --global color.diff.old "red bold"
git config --global color.diff.new "green bold"
git config --global color.status.added "yellow"
git config --global color.status.changed "green"
git config --global color.status.untracked "cyan"
# Push configurations
git config --global push.default "current"
# Pager configurations
git config --global pager.diff "diff-so-fancy | less --tabs=1,5 -RFX"
git config --global pager.show "diff-so-fancy | less --tabs=1,5 -RFX"
# Alias configurations
git config --global alias.a "add"
git config --global alias.br "branch"
git config --global alias.ca "commit --amend"
git config --global alias.ci "commit"
git config --global alias.co "checkout"
git config --global alias.dfc "diff --cached"
git config --global alias.df "diff"
git config --global alias.fix "commit -am 'fix'"
git config --global alias.last "describe --abbrev=0 --tags"
git config --global alias.lbranch "log --graph --simplify-by-decoration --pretty=format:'%C(yellow)%h%C(white)%d %C(bold black)%ar %C(reset)%n' --all"
git config --global alias.lg "log -p"
git config --global alias.lola "log --graph --decorate --pretty=oneline --abbrev-commit --all"
git config --global alias.lol "log --graph --decorate --pretty=oneline --abbrev-commit"
git config --global alias.ls "ls-files"
git config --global alias.pl "pull"
git config --global alias.ps "push"
git config --global alias.purge "!git checkout $(git rev-parse --abbrev-ref origin/HEAD | cut -d/ -f2-) && git pull && git remote prune origin && git branch --merged | grep -v '^\\*' | grep -v $(git rev-parse --abbrev-ref origin/HEAD | cut -d/ -f2-) | xargs -r git branch -D"
git config --global alias.refactor "commit -am 'refactor'"
git config --global alias.report "!git for-each-ref --sort=committerdate --format='%(refname:short) * %(authorname) * %(committerdate:relative)' refs/remotes/ | column -t -s '*'"
git config --global alias.rpo "remote prune origin"
git config --global alias.rso "remote show origin"
git config --global alias.st "status -sb"
git config --global alias.who "shortlog -s --"
# Pull configurations
git config --global pull.ff "only"
echo "Please set up the following Git options manually:"
echo 'git config --global github.user "john"'
echo 'git config --global user.name "John Doe"'
echo 'git config --global user.email "johndoe@example.com"'
}
setup_foot() {
foot_config_dir="${HOME}/.config/foot"
echo "Configure foot"
mkdir -p "$foot_config_dir"
for file in "${here}/footfiles"/*; do
name="$(basename "$file")"
ln -sfv "$file" "${foot_config_dir}/${name}"
done
}
setup_fish() {
fish_config_dir="${HOME}/.config/fish"
echo "Install fishfiles"
mkdir -p "$fish_config_dir"
for file in "${here}/fishfiles"/*; do
name="$(basename "$file")"
ln -sfv "$file" "${HOME}/.config/fish/${name}"
done
fish -c "fundle install"
fish -c fish_update_completions
}
setup_helix() {
helix_config_dir="${HOME}/.config/helix"
echo "Configure helix"
mkdir -p "$helix_config_dir"
for file in "${here}/helixfiles"/*; do
name="$(basename "$file")"
ln -sfv "$file" "${helix_config_dir}/${name}"
done
}
setup_tmux() {
echo "Setup tmux"
if [[ ! -d ~/.tmux/plugins/tpm ]]; then
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
fi
~/.tmux/plugins/tpm/bin/install_plugins
}
install_fzf() {
fzf_directory="${HOME}/.fzf"
if [[ ! -d $fzf_directory ]]; then
echo "Install FZF"
git clone --depth 1 https://github.com/junegunn/fzf.git "$fzf_directory"
cd "$fzf_directory" && ./install --all --no-bash --no-zsh
fi
}
install_rbenv() {
if [[ ! -d ~/.rbenv ]]; then
echo "Install rbenv"
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
~/.rbenv/bin/rbenv init
mkdir -p ~/.rbenv/plugins
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
fi
}
install_skyspell() {
echo "Install skyspell"
sudo apt install -y libsqlite3-dev libenchant-2-dev aspell aspell-en
cargo install --quiet skyspell --version 1.0.1 --locked
cargo install --quiet skyspell_kak --version 1.0.1 --locked
}
install_nerd_font() {
local font_dir="${HOME}/.local/share/fonts"
local font_name="Inconsolata"
local font_zip="${font_name}.zip"
local download_url="https://github.com/ryanoasis/nerd-fonts/releases/latest/download/${font_zip}"
if fc-list | grep -qi "Inconsolata.*Nerd"; then
echo "Inconsolata Nerd Font already installed"
return
fi
echo "Install Inconsolata Nerd Font"
mkdir -p "$font_dir"
wget -q -O "/tmp/${font_zip}" "$download_url"
unzip -o -q "/tmp/${font_zip}" -d "${font_dir}/InconsolataNerdFont"
rm "/tmp/${font_zip}"
fc-cache -f
}
install_helix() {
echo "Install Helix editor"
local helix_dir="${HOME}/.local/share/helix"
local latest_url
local tarball
latest_url=$(wget -qO- "https://api.github.com/repos/helix-editor/helix/releases/latest" \
| grep -oP '"browser_download_url": "\K[^"]+x86_64-linux\.tar\.xz')
if [[ -z "$latest_url" ]]; then
echo "Failed to find Helix download URL"
return 1
fi
tarball="/tmp/helix.tar.xz"
wget -q -O "$tarball" "$latest_url"
rm -rf "$helix_dir"
mkdir -p "$helix_dir"
tar -xJf "$tarball" -C "$helix_dir" --strip-components=1
rm "$tarball"
ln -sfv "${helix_dir}/hx" "${HOME}/.local/bin/hx"
}
install_marksman() {
echo "Install Marksman LSP"
local latest_url
local binary="/tmp/marksman"
latest_url=$(wget -qO- "https://api.github.com/repos/artempyanykh/marksman/releases/latest" \
| grep -oP '"browser_download_url": "\K[^"]+marksman-linux-x64')
if [[ -z "$latest_url" ]]; then
echo "Failed to find Marksman download URL"
return 1
fi
wget -q -O "$binary" "$latest_url"
chmod +x "$binary"
mv "$binary" "${HOME}/.local/bin/marksman"
}
do_all() {
install_submodules
install_basic_packages
remove_unnecessary_packages
install_local_bin
link_dotfiles
setup_git
setup_foot
install_helix
install_marksman
setup_helix
setup_tmux
install_fzf
install_rbenv
setup_fish
install_skyspell
install_nerd_font
}
do_all
echo 'Change your shell with chsh -s $(which fish)'
echo 'Then setup rbenv with'
echo 'set -Ux fish_user_paths $HOME/.rbenv/bin $fish_user_paths'