-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.bash
More file actions
181 lines (158 loc) · 4.54 KB
/
install.bash
File metadata and controls
181 lines (158 loc) · 4.54 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
#!/bin/bash
# shellcheck disable=1091
# Note this script is to be run on Debian and is intended to be sourced not executed!
# It will fail on other distros, even Debian-derivatives like Ubuntu. For example,
# Ubuntu doesn't have `kitty`, and it downloads an older version of `stow` that doesn't
# support the `--dotfiles` option. There could be other issues, too.
# Deal with it.
set -eo pipefail
if [ "${BASH_SOURCE[0]}" = "${0}" ]
then
echo -e "This script is not intended to be executed!\nSource it instead."
exit 1
fi
install_package() {
local package="$1"
if ! command -v "$package" > /dev/null
then
sudo apt-get install --no-install-recommends --yes "$package"
printf "%b Installed package \`%s\`.\n" "$SUCCESS" "$package"
fi
}
# For colored output in this file :)
install_package tput
SUCCESS="$(tput setaf 5)[$0] $(tput setaf 2)[SUCCESS]$(tput sgr0)"
PACKAGES=(
bash-completion
bat
bc
bsdmainutils
cowsay
curl
debootstrap
dmenu
exuberant-ctags
feh
fonts-noto
fortune
gdb
git
i3
i3lock
i3status
kitty
podman
# python3
# python3-pip
silversearcher-ag
stow
tmux
tree
# Install the `setxkbmap` binary needed by `.bash_options` (sets caps lock to ctrl key).
x11-xkb-utils
xsel
vim
wget
)
for package in "${PACKAGES[@]}"
do
install_package "$package"
done
DEFAULT_FILES=(
"$HOME/.bash"*
"$HOME/.vim"*
"$HOME/.tmux"*
"$HOME"/.gitconfig
"$HOME"/.local/{bin,share}/gh-hooker
)
for LOCATION in "${DEFAULT_FILES[@]}"
do
rm -rf "$LOCATION"
done
TOOLS=(
bash
gdb
git
git-tools
gnupg
i3
systemd
templates
tmux
vim
xinit
)
for tool in "${TOOLS[@]}"
do
case "$tool" in
git-tools)
podman run --rm -v "$HOME/.local":/root/.local docker.io/btoll/gh-hooker:latest
;;
gnupg)
mkdir -p "$HOME/.$tool"
stow --target "$HOME/.$tool" "$tool"
;;
i3)
mkdir -p "$HOME/.config/$tool"
stow --target "$HOME/.config/$tool" "$tool"
;;
systemd)
sudo cp "$tool"/* "/lib/systemd/system"
;;
templates)
mkdir -p "$HOME/$tool"
stow --target "$HOME/$tool" "$tool"
;;
vim)
stow --dotfiles --target "$HOME" "$tool"
# This is a kludge. The `ftplugin` dir will be installed to
# the home dir, so remove it and then put it in its proper
# location.
# Note that we're removing it rather than moving it to `.vim/`
# because the files aren't linked (they will be below).
rm -rf "$HOME/ftplugin"
# Now, put `ftplugin` in its right spot and link them.
mkdir -p "$HOME/.$tool/ftplugin"
stow --target "$HOME/.$tool/ftplugin" --dir "$tool" ftplugin
;;
*)
stow --dotfiles --target "$HOME" "$tool"
;;
esac
printf "%b Installed \`%s\` dotfile(s).\n" "$SUCCESS" "$tool"
done
# Download other dev dependencies.
# fzf
# vim-plug
# We could go through contortions to determine if the pubkey is already in
# known_hosts, but it's not worth it just to prevent a possible duplicate.
ssh-keyscan github.com >> "$HOME/.ssh/known_hosts"
ssh-keyscan gitlab.com >> "$HOME/.ssh/known_hosts"
# https://github.com/junegunn/fzf
# `~/.fzf/bin` is appended to `PATH` when `~/.fzf.bash` is sourced in `.bash_vendor`.
if [ ! -d "$HOME/.fzf" ]
then
git clone --depth 1 https://github.com/junegunn/fzf.git "$HOME/.fzf"
"$HOME/.fzf/install" --completion --key-bindings --no-update-rc
printf "%b Installed \`fzf\`.\n" "$SUCCESS"
fi
# This is needed to auto-install any tmux plugins.
# See `$HOME/.tmux.conf`.
git clone https://github.com/tmux-plugins/tpm "$HOME/.tmux/plugins/tpm"
if [ ! -d "$HOME/.vim/autoload" ] || [ ! -f "$HOME/.vim/autoload/plug.vim" ]
then
# https://github.com/junegunn/vim-plug
curl -fLo "$HOME/.vim/autoload/plug.vim" --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
printf "%b Installed \`vim-plug\`.\n" "$SUCCESS"
fi
# Install vim plugins.
# + is just a shorthand notation of -c (command).
# +qa = quit all
vim +'PlugInstall --sync' +qa
printf "%b Installed vim plugins.\n" "$SUCCESS"
source "$HOME/.fzf.bash"
source "$HOME/.bash_profile"
printf "%b The dotfiles and dev dependencies have been succesfully installed!\n" "$SUCCESS"
#. install.d/
#vagrant plugin install vagrant-libvirt