-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake.sh
executable file
·289 lines (251 loc) · 13.7 KB
/
make.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
#!/usr/bin/env bash
############################
# .make.sh
# This script creates symlinks from the home directory to any desired dotfiles in $HOME/dotfiles
############################
. "$(dirname "$0")/Common/shell/common.sh"
CURRENT_SHELL=$(find_current_shell)
CURRENT_HOST=$(hostname)
CURRENT_OS=$(find_os)
DOTFILES_DIR=$(find_dotfiles)
echo ">>> Running ($CURRENT_SHELL) for '$CURRENT_HOST' on '$CURRENT_OS' at '$DOTFILES_DIR'."
install_shell() {
case $1 in
bash)
if type bash > /dev/null 2>&1; then
# Set the default shell to bash if it isn't currently set to bash
if [ ! "$(readlink /proc/$$/exe)" = "$(which bash)" ]; then
chsh -s "$(which bash)"
echo ">>> You need to re-login :( "
fi
else
# Bash not installed
[ -f /etc/fedora-release ] && sudo dnf install bash || exit 1
[ -f /etc/debian_version ] && sudo apt install bash || exit 1
# Run again
install_shell "bash"
fi
;;
zsh)
if type zsh > /dev/null 2>&1; then
# Set the default shell to zsh if it isn't currently set to zsh
if [ ! "$(readlink /proc/$$/exe)" = "$(which zsh)" ]; then
chsh -s "$(which zsh)"
echo ">>> You need to re-login :( "
fi
else
# Zsh not installed
[ -f /etc/fedora-release ] && sudo dnf install zsh || exit 1
[ -f /etc/debian_version ] && sudo apt install zsh || exit 1
# Run again
install_shell "zsh"
fi
;;
*)
echo ">>> Unknown shell ($1), exiting..." && exit 1
;;
esac
}
install_emacs() {
if ! type emacs > /dev/null 2>&1; then
echo ">>> Emacs is not installed, exiting..." && exit 1
fi
# Install Doom Emacs
# if [ ! -d "$DOTFILES_DIR/.emacs.doom" ]; then
# echo ">>> Installing Doom Emacs at $DOTFILES_DIR/.emacs.doom"
# git clone [email protected]:hlissner/doom-emacs.git "$DOTFILES_DIR/.emacs.doom"
# check $?
#
# env EMACSDIR="$DOTFILES_DIR/.emacs.doom" \
# env DOOMDIR="$DOTFILES_DIR/Common/emacs/doom" \
# "$DOTFILES_DIR/.emacs.doom/bin/doom" install
# check $?
# fi
# Install Crafted Emacs
# if [ ! -d "$DOTFILES_DIR/.emacs.crafted" ]; then
# echo ">>> Installing Crafted Emacs at $DOTFILES_DIR/.emacs.crafted"
# git clone --depth 1 [email protected]:SystemCrafters/crafted-emacs.git "$DOTFILES_DIR/.emacs.crafted"
# check $?
# fi
# Install Prelude
# if [ ! -d "$DOTFILES_DIR/.emacs.prelude" ]; then
# echo ">>> Installing Prelude Emacs at $DOTFILES_DIR/.emacs.prelude"
# curl -L https://github.com/bbatsov/prelude/raw/master/utils/installer.sh |
# env PRELUDE_INSTALL_DIR="$DOTFILES_DIR/.emacs.prelude" sh
# check $?
# fi
# Install yasnippet shim for treesitter (lives on personal/etc)
# if [ ! -d "$DOTFILES_DIR/.yasnippet-treesitter-shim" ]; then
# echo ">>> Installing Yasnippet Treesitter Ship at $DOTFILES_DIR/.yasnippet-treesitter-shim"
# git clone [email protected]:fbrosda/yasnippet-treesitter-shim.git "$DOTFILES_DIR/.yasnippet-treesitter-shim"
# check $?
# fi
# Install Emacs Minimal
# if [ ! -d "$DOTFILES_DIR/.emacs.minimal" ]; then
# echo ">>> Installing Emacs Minimal at $DOTFILES_DIR/.emacs.minimal"
# git clone --depth 1 [email protected]:jamescherti/minimal-emacs.d.git "$DOTFILES_DIR/.emacs.minimal"
# check $?
# else
# echo ">>> Updating Emacs Minimal at $DOTFILES_DIR/.emacs.minimal"
# git -C "$DOTFILES_DIR/.emacs.minimal" pull
# fi
}
install_shell "bash"
# install_emacs
echo ">>> Linking common files in $HOME..."
files=".inputrc .editorconfig .sbclrc .mbsyncrc .msmtprc .tidyrc"
[ -n "$BASH_VERSION" ] && files+=" .bash_profile .bashrc"
[ -n "$ZSH_VERSION" ] && files+=" .zshenv .zshrc"
for file in $files; do
[ -L "$HOME/$file" ] && unlink "$HOME/$file"
ln -s "$DOTFILES_DIR/Common/$file" "$HOME/"
done
echo ">>> Linking common files in $HOME/.config..."
files="git btop nyxt alacritty foot ghostty shell tmux zellij ranger rofi psd i3 nushell keyd xkeysnail xremap starship.toml clangd"
for file in $files; do
[ -L "$HOME/.config/$file" ] && unlink "$HOME/.config/$file"
ln -s "$DOTFILES_DIR/Common/$file" "$HOME/.config"
done
echo ">>> Linking nvim files in $HOME/.config..."
for dir in "$DOTFILES_DIR"/Common/nvim/*/; do
dir=${dir%*/}
dir_name=${dir##*/}
[ -L "$HOME/.config/nvim-${dir_name}" ] && unlink "$HOME/.config/nvim-${dir_name}"
ln -s "$dir" "$HOME/.config/nvim-${dir_name}"
done
echo ">>> Linking scripts files in $HOME/.local/bin..."
for file in "$DOTFILES_DIR"/Common/shell/scripts/*; do
[ -L "$HOME"/.local/bin/"$(basename "$file")" ] && unlink "$HOME"/.local/bin/"$(basename "$file")"
ln -s "$file" "$HOME"/.local/bin
done
echo ">>> Linking systemd user files in $HOME/.config/systemd/user..."
files="emacs.service xkeysnail.service xremap.service mullvad.service"
for file in $files; do
[ -L "$HOME/.config/systemd/user/$file" ] && unlink "$HOME/.config/systemd/user/$file"
ln -s "$DOTFILES_DIR/Common/systemd/user/$file" "$HOME/.config/systemd/user"
done
echo ">>> Linking desktop application files in $HOME/.local/share/applications..."
files="emacs.desktop emacsclient.desktop thinkorswim.desktop"
for file in $files; do
# Unfortunaly symlinks don't work on KDE, so copy instead
cp -f "$DOTFILES_DIR/Common/applications/$file" "$HOME/.local/share/applications"
done
echo ">>> Linking flatpak application files in $HOME/.var/app/..."
if [ -d "$HOME/.var/app/engineer.atlas.Nyxt/config/" ]; then
[ -L "$HOME/.var/app/engineer.atlas.Nyxt/config/nyxt" ] && unlink "$HOME/.var/app/engineer.atlas.Nyxt/config/nyxt"
ln -s "$DOTFILES_DIR/Common/nyxt" "$HOME/.var/app/engineer.atlas.Nyxt/config/"
fi
echo ">>> Linking work files in $HOME/Workspace/Work..."
if [ -d "$HOME/Workspace/Work/Omicron/Projects" ]; then
[ -L "$HOME/Workspace/Work/Omicron/Projects/.gitconfig" ] &&
unlink "$HOME/Workspace/Work/Omicron/Projects/.gitconfig"
ln -s "$DOTFILES_DIR/Misc/work/.gitconfig" "$HOME/Workspace/Work/Omicron/Projects"
# Using git worktrees
worktrees="main review scratch dev fuzz"
for worktree in $worktrees; do
[ ! -d "$HOME/Workspace/Work/Omicron/Projects/nntp/$worktree/" ] && continue
[ -L "$HOME/Workspace/Work/Omicron/Projects/nntp/$worktree/compile_flags.txt" ] &&
unlink "$HOME/Workspace/Work/Omicron/Projects/nntp/$worktree/compile_flags.txt"
if [ -f /etc/fedora-release ]; then
ln -s "$DOTFILES_DIR/Misc/work/nntp/compile_flags.fedora.txt" \
"$HOME/Workspace/Work/Omicron/Projects/nntp/$worktree/compile_flags.txt"
elif [ -f /etc/debian_version ]; then
ln -s "$DOTFILES_DIR/Misc/work/nntp/compile_flags.debian.txt" \
"$HOME/Workspace/Work/Omicron/Projects/nntp/$worktree/compile_flags.txt"
elif [ -f /etc/products.d/openSUSE.prod ]; then
ln -s "$DOTFILES_DIR/Misc/work/nntp/compile_flags.suse.txt" \
"$HOME/Workspace/Work/Omicron/Projects/nntp/$worktree/compile_flags.txt"
else
echo ">>> Unknown OS (only fedora and debian are supported)..." && continue
fi
# [ -L "$HOME/Workspace/Work/Omicron/Projects/nntp/$worktree/.clangd" ] &&
# unlink "$HOME/Workspace/Work/Omicron/Projects/nntp/$worktree/.clangd"
# ln -s "$DOTFILES_DIR/Misc/.clangd" "$HOME/Workspace/Work/Omicron/Projects/nntp/$worktree"
[ -L "$HOME/Workspace/Work/Omicron/Projects/nntp/$worktree/.clang-tidy" ] &&
unlink "$HOME/Workspace/Work/Omicron/Projects/nntp/$worktree/.clang-tidy"
ln -s "$DOTFILES_DIR/Misc/work/nntp/.clang-tidy" "$HOME/Workspace/Work/Omicron/Projects/nntp/$worktree"
[ -L "$HOME/Workspace/Work/Omicron/Projects/nntp/$worktree/.dir-locals.el" ] &&
unlink "$HOME/Workspace/Work/Omicron/Projects/nntp/$worktree/.dir-locals.el"
ln -s "$DOTFILES_DIR/Misc/work/nntp/.dir-locals.el" "$HOME/Workspace/Work/Omicron/Projects/nntp/$worktree/"
done
# Without using git worktrees
# if [ -d "$HOME/Workspace/Work/Omicron/Projects/nntpcode" ]; then
# [ -L "$HOME/Workspace/Work/Omicron/Projects/nntpcode/compile_flags.txt" ] &&
# unlink "$HOME/Workspace/Work/Omicron/Projects/nntpcode/compile_flags.txt"
# if [ -f /etc/fedora-release ]; then
# ln -s "$DOTFILES_DIR/Misc/work/nntpcode/compile_flags.fedora.txt" \
# "$HOME/Workspace/Work/Omicron/Projects/nntpcode/compile_flags.txt"
# elif [ -f /etc/debian_version ]; then
# ln -s "$DOTFILES_DIR/Misc/work/nntpcode/compile_flags.debian.txt" \
# "$HOME/Workspace/Work/Omicron/Projects/nntpcode/compile_flags.txt"
# elif [ -f /etc/products.d/openSUSE.prod ]; then
# ln -s "$DOTFILES_DIR/Misc/work/nntpcode/compile_flags.suse.txt" \
# "$HOME/Workspace/Work/Omicron/Projects/nntpcode/compile_flags.txt"
# else
# echo ">>> Unknown OS (only fedora and debian are supported)..."
# fi
# # [ -L "$HOME/Workspace/Work/Omicron/Projects/nntpcode/.clangd" ] &&
# # unlink "$HOME/Workspace/Work/Omicron/Projects/nntpcode/.clangd"
# # ln -s "$DOTFILES_DIR/Misc/.clangd" "$HOME/Workspace/Work/Omicron/Projects/nntpcode/"
# [ -L "$HOME/Workspace/Work/Omicron/Projects/nntpcode/.clang-tidy" ] &&
# unlink "$HOME/Workspace/Work/Omicron/Projects/nntpcode/.clang-tidy"
# ln -s "$DOTFILES_DIR/Misc/work/nntpcode/.clang-tidy" "$HOME/Workspace/Work/Omicron/Projects/nntpcode/"
# [ -L "$HOME/Workspace/Work/Omicron/Projects/nntpcode/.dir-locals.el" ] &&
# unlink "$HOME/Workspace/Work/Omicron/Projects/nntpcode/.dir-locals.el"
# ln -s "$DOTFILES_DIR/Misc/work/nntpcode/.dir-locals.el" "$HOME/Workspace/Work/Omicron/Projects/nntpcode/"
# fi
fi
if [ -d "$HOME/Workspace/Work/Nielsen" ]; then
[ -L "$HOME/Workspace/Work/Nielsen/.gitconfig" ] && unlink "$HOME/Workspace/Work/Nielsen/.gitconfig"
ln -s "$DOTFILES_DIR/Misc/work/.gitconfig" "$HOME/Workspace/Work/Nielsen"
if [ -d "$HOME/Workspace/Work/Nielsen/Projects/dmxs" ]; then
[ -L "$HOME/Workspace/Work/Nielsen/Projects/dmxs/compile_flags.txt" ] &&
unlink "$HOME/Workspace/Work/Nielsen/Projects/dmxs/compile_flags.txt"
if [ -f /etc/fedora-release ]; then
ln -s "$DOTFILES_DIR/Misc/work/dmxs/compile_flags.fedora.txt" \
"$HOME/Workspace/Work/Nielsen/Projects/dmxs/compile_flags.txt"
elif [ -f /etc/debian_version ]; then
ln -s "$DOTFILES_DIR/Misc/work/dmxs/compile_flags.debian.txt" \
"$HOME/Workspace/Work/Nielsen/Projects/dmxs/compile_flags.txt"
elif [ -f /etc/products.d/openSUSE.prod ]; then
ln -s "$DOTFILES_DIR/Misc/work/dmxs/compile_flags.suse.txt" \
"$HOME/Workspace/Work/Nielsen/Projects/dmxs/compile_flags.txt"
else
echo ">>> Unknown OS (only fedora and debian are supported)..."
fi
# [ -L "$HOME/Workspace/Work/Nielsen/Projects/dmxs/.clangd" ] &&
# unlink "$HOME/Workspace/Work/Nielsen/Projects/dmxs/.clangd"
# ln -s "$DOTFILES_DIR/Misc/.clangd" "$HOME/Workspace/Work/Nielsen/Projects/dmxs/"
[ -L "$HOME/Workspace/Work/Nielsen/Projects/dmxs/.dir-locals.el" ] &&
unlink "$HOME/Workspace/Work/Nielsen/Projects/dmxs/.dir-locals.el"
ln -s "$DOTFILES_DIR/Misc/work/dmxs/.dir-locals.el" "$HOME/Workspace/Work/Nielsen/Projects/dmxs/"
fi
if [ -d "$HOME/Workspace/Work/Nielsen/Projects/sm2-dhcpee" ]; then
[ -L "$HOME/Workspace/Work/Nielsen/Projects/sm2-dhcpee/compile_flags.txt" ] &&
unlink "$HOME/Workspace/Work/Nielsen/Projects/sm2-dhcpee/compile_flags.txt"
if [ -f /etc/fedora-release ]; then
ln -s "$DOTFILES_DIR/Misc/work/sm2-dhcpee/compile_flags.fedora.txt" \
"$HOME/Workspace/Work/Nielsen/Projects/sm2-dhcpee/compile_flags.txt"
elif [ -f /etc/debian_version ]; then
ln -s "$DOTFILES_DIR/Misc/work/sm2-dhcpee/compile_flags.debian.txt" \
"$HOME/Workspace/Work/Nielsen/Projects/sm2-dhcpee/compile_flags.txt"
elif [ -f /etc/products.d/openSUSE.prod ]; then
ln -s "$DOTFILES_DIR/Misc/work/sm2-dhcpee/compile_flags.suse.txt" \
"$HOME/Workspace/Work/Nielsen/Projects/sm2-dhcpee/compile_flags.txt"
else
echo ">>> Unknown OS (only fedora and debian are supported)..."
fi
# [ -L "$HOME/Workspace/Work/Nielsen/Projects/sm2-dhcpee/ /.clangd" ] &&
# unlink "$HOME/Workspace/Work/Nielsen/Projects/sm2-dhcpee/ /.clangd"
# ln -s "$DOTFILES_DIR/Misc/.clangd" "$HOME/Workspace/Work/Nielsen/Projects/sm2-dhcpee/"
[ -L "$HOME/Workspace/Work/Nielsen/Projects/sm2-dhcpee/.dir-locals.el" ] &&
unlink "$HOME/Workspace/Work/Nielsen/Projects/sm2-dhcpee/.dir-locals.el"
ln -s "$DOTFILES_DIR/Misc/work/sm2-dhcpee/.dir-locals.el" "$HOME/Workspace/Work/Nielsen/Projects/sm2-dhcpee/"
fi
if [ -d "$HOME/Workspace/Work/Nielsen/Projects/smi" ]; then
[ -L "$HOME/Workspace/Work/Nielsen/Projects/smi/.dir-locals.el" ] &&
unlink "$HOME/Workspace/Work/Nielsen/Projects/smi/.dir-locals.el"
ln -s "$DOTFILES_DIR/Misc/work/smi/.dir-locals.el" "$HOME/Workspace/Work/Nielsen/Projects/smi/"
fi
fi
echo ">>> All Done!"