-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup
executable file
·366 lines (307 loc) · 13.5 KB
/
setup
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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
#!/bin/bash
minimal() {
# install minimal cli tools
sudo apt-get update
sudo apt-get install -y \
curl \
git \
ssh \
tree \
vim \
zsh
zsh zsh/plugin-files/zap_zsh_install # minimal zsh plugin manager
sudo chsh -s "$(which zsh)" "$USER" # set zsh as default shell
fuzzy_finder
terminal_theme
sudo mkdir -p /usr/local/bin
sudo ln -s ~/bin/* /usr/local/bin/
}
cli() {
# idempotently installs cli utils
sudo apt-get update
sudo apt-get install -y \
curl \
git \
jq \
libfuse2 \
make \
neofetch \
nvtop \
python3 \
python3-pip \
ripgrep \
ssh \
tree \
vim \
xclip \
zsh
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash && git lfs install
zsh zsh/plugin-files/zap_zsh_install # minimal zsh plugin manager
sudo chsh -s "$(which zsh)" "$USER" # set zsh as default shell
fuzzy_finder
terminal_theme
# htop but based (install from source for gpu support)
cd "$HOME/repos/tools" && { if [ -d "btop" ]; then cd btop && git pull; else git clone --depth 1 https://github.com/aristocratos/btop.git && cd btop; fi; sudo make && sudo make install; }
# faster pip
curl -LsSf https://astral.sh/uv/install.sh | sh
sudo mkdir -p /usr/local/bin
sudo ln -s ~/bin/* /usr/local/bin/
# fastfetch on ubuntu 22.04+
if grep -q "Ubuntu" /etc/os-release && [ "$(awk -F'=' '/VERSION_ID/{print $2}' /etc/os-release | tr -d '\"' | awk -F'.' '{if ($1 > 22 || ($1 == 22 && $2 >= 4)) print 1; else print 0}')" -eq 1 ]; then
yes | sudo add-apt-repository ppa:zhangsongcui3371/fastfetch
sudo apt update
sudo apt install -y fastfetch
fi
nvim
touch ~/.local_exports
}
ubuntu() {
cli
sudo apt-get install -y \
baobab \
blueman \
gnome-shell-extensions-gpaste \
gparted \
pulseaudio-module-bluetooth \
virt-viewer
./bin/keybindings.pl -i
# disable screenshot sound
if [ -f "/usr/share/sounds/freedesktop/stereo/camera-shutter.oga" ]; then
sudo mv /usr/share/sounds/freedesktop/stereo/camera-shutter.oga /usr/share/sounds/freedesktop/stereo/camera-shutter-disabled.oga
fi
# webp support for eye of gnome image viewer
# yes | sudo add-apt-repository ppa:helkaluin/webp-pixbuf-loader (ships with >=22.04)
sudo apt install webp-pixbuf-loader
xdg-mime default org.gnome.eog.desktop image/webp
# encrypted volumes
yes | sudo add-apt-repository ppa:unit193/encryption
sudo apt-get update
sudo apt-get install -y veracrypt
obsidian
obsidian_vault desktop shallow
syncthing
### remove bloat
# screen reader
sudo apt-get remove -y orca
# braille display driver
sudo apt-get remove -y brltty
}
android() {
# https://android.stackexchange.com/a/185949
pkg update && pkg upgrade
pkg install python gh fastfetch git-lfs zsh vim htop
git lfs install
ln -sf ~/storage/shared/repos ~/repos # can't do it the other way round without root
obsidian_vault mobile shallow
git config --global --add safe.directory ~/storage/shared/repos/obsidian/knowledge-base
zsh zsh/plugin-files/zap_zsh_install # minimal zsh plugin manager
chsh -s zsh # set zsh as default shell
fuzzy_finder
terminal_theme
echo "source ~/.dotfiles/zsh/android" >> ~/.zshrc
}
docker() {
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh ./get-docker.sh
sudo usermod -a -G docker $USER
rm get-docker.sh
echo "Reboot to apply changes"
}
fuzzy_finder() {
if [ ! -d "$HOME/.fzf" ]; then git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf; fi;
cd ~/.fzf && git pull && ~/.fzf/install
}
terminal_theme() {
curl -sSL "https://github.com/zthxxx/jovial/raw/master/jovial.zsh-theme" -o ~/.dotfiles/zsh/plugin-files/mytheme.zsh-theme
pip3 install --user pywal
}
miniconda() {
mkdir -p ~/miniconda
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh -b -u -p ~/miniconda # batch (no questions) mode, update, path
~/miniconda/bin/conda init zsh
rm Miniconda3-latest-Linux-x86_64.sh
echo "To use miniconda, add the following to your .zshrc and start a new shell: PATH=~/miniconda/bin:$PATH"
}
mamba() {
curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh"
bash Miniforge3-Linux-x86_64.sh -b
rm Miniforge3-Linux-x86_64.sh
conda config --append envs_dirs ~/miniconda3/envs/
}
nvim() {
local appimage_url="https://github.com/neovim/neovim/releases/latest/download/nvim.appimage"
local appimage_dir="$HOME/applications"
local appimage_path="$appimage_dir/nvim.AppImage"
echo "Downloading latest Neovim AppImage..."
wget -O "$appimage_path" "$appimage_url"
chmod +x "$appimage_path"
echo "Neovim AppImage downloaded and set up at $appimage_path"
# echo "Setting up nerd-fonts"
# curl -o ~/.local/share/fonts/font.tar.xz -L https://github.com/ryanoasis/nerd-fonts/releases/latest/download/UbuntuSans.tar.xz && tar -xf ~/.local/share/fonts/font.tar.xz -C ~/.local/share/fonts && rm ~/.local/share/fonts/font.tar.xz && fc-cache -fv
}
toolbox() {
curl -fsSL https://raw.githubusercontent.com/nagygergo/jetbrains-toolbox-install/master/jetbrains-toolbox.sh | bash
cd ~/.local/bin/ && ./jetbrains-toolbox
}
act() {
# local github actions runner
curl -s https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo zsh
}
get_restic() {
# backup tool
sudo apt-get install -y restic
sudo restic self-update
echo "restic installed and updated"
echo "to schedule backup:\nsudo -e /etc/anacrontab\n7 7 $HOME/.dotfiles/bin/restic_backup $HOME/backup/restic_repos/<XXX> $HOME/.dotfiles/secrets/passwords/restic_<XXX>"
}
secrets() {
if [ ! -f ~/.dotfiles/secrets/.encryption_key ]; then
if ! [ -d "secrets" ]; then
git clone git@github.com:MaxWolf-01/secrets.git
fi
echo "Please provide the encryption key in ~/.dotfiles/secrets/.encryption_key then run the script again."
return
fi
cd ~/.dotfiles/secrets && git pull
ln -sf ~/.dotfiles/git/hooks/pre_commit_encrypt ~/.dotfiles/secrets/.git/hooks/pre-commit
ln -sf ~/.dotfiles/git/hooks/post_commit_decrypt ~/.dotfiles/secrets/.git/hooks/post-commit
bash ~/.dotfiles/bin/decrypt_enc_files # on first run, decrypt all files (non-encrypted are .gitignored)
ln -sf ~/.dotfiles/secrets/ssh/config ~/.ssh/config
# find ~/.dotfiles/secrets/bin -type f -exec ln -sf {} ~/bin/ \;
}
vim_copilot() {
git clone --depth 1 https://github.com/github/copilot.vim.git ~/.vim/pack/github/start/copilot.vim
}
rm_conda() {
rm -rf ~/miniconda
rm -rf ~/.condarc ~/.conda ~/.continuum
rm -rf ~/miniforge3
}
syncthing () {
sudo mkdir -p /etc/apt/keyrings
sudo curl -L -o /etc/apt/keyrings/syncthing-archive-keyring.gpg https://syncthing.net/release-key.gpg
echo "deb [signed-by=/etc/apt/keyrings/syncthing-archive-keyring.gpg] https://apt.syncthing.net/ syncthing stable" | sudo tee /etc/apt/sources.list.d/syncthing.list
sudo apt-get update
sudo apt-get install syncthing
systemctl --user enable syncthing.service
systemctl --user start syncthing.service
# todo make syncthingtray work vis apt
}
install_nodejs() {
sudo apt-get update && sudo apt-get install -y ca-certificates curl gnupg
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
NODE_MAJOR=21
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
sudo apt-get update && sudo apt-get install nodejs -y
sudo npm install -g pnpm
}
obsidian_vault() {
local platform=${1:-desktop} # Default to desktop if no argument provided
local depth=${2:-full} # Default to full clone if no depth specified
local depth_arg=""
if [ "$depth" = "shallow" ]; then
depth_arg="--depth 1"
fi
path=~/repos/obsidian
if [ "$platform" = "mobile" ]; then
path=~/storage/shared/obsidian
fi
mkdir -pv "$path" && cd "$path" || exit
if [ -d "knowledge-base" ]; then
echo "knowledge-base already exists"
return
fi
git clone $depth_arg git@github.com:MaxWolf-01/knowledge-base.git
cd knowledge-base || exit
git clone $depth_arg git@github.com:MaxWolf-01/.obsidian
cd .obsidian && ./switch_platform.sh "$platform" || exit
ln -sf ~/.dotfiles/vim/obsidian "$path/knowledge-base/.obsidian.vimrc"
ln -sf ~/.dotfiles/git/hooks/check_question_mark_in_filename "$path/knowledge-base/.git/hooks/pre-commit"
}
obsidian() {
appimage="$(find ~/Downloads -name 'Obsidian*.AppImage')"
if [ -z "$appimage" ]; then
echo "Error: No Obsidian AppImage found in Downloads."
exit 1
fi
COUNT=$(echo "$appimage" | wc -l)
if [ $COUNT -gt 1 ]; then
echo "Warning: Multiple Obsidian AppImages found. Using the first one."
fi
appimage=$(echo "$appimage" | head -n 1)
echo "Using Obsidian AppImage: $appimage"
mv "$appimage" ~/applications/obsidian.AppImage
chmod +x ~/applications/obsidian.AppImage
sed "s|\$HOME|$HOME|g" "$HOME"/.dotfiles/desktop/obsidian.desktop > "$HOME"/.local/share/applications/obsidian.desktop
update-desktop-database "$HOME"/.local/share/applications/
echo "Obsidian app set up."
}
discord() { # will setup discord and betterdiscord on first run, update both on subsequent runs; after discord update run this second time to apply betterdiscord changes
if [ "$EUID" -eq 0 ]; then echo "Don't run as root!"; return; fi
if ! command -v npm &> /dev/null || ! command -v pnpm &> /dev/null; then echo "npm or pnpm not found. Run './setup install_nodejs'"; return; fi
cd ~/repos/tools || echo "Error: $HOME/repos/tools does not exist" || exit 1
if [ -d ~/repos/tools/BetterDiscord ]; then cd BetterDiscord && git pull; else git clone --depth 1 https://github.com/BetterDiscord/BetterDiscord.git && cd BetterDiscord; fi; # get latest betterdiscord
if [ ! -f discord.old.deb ]; then wget -O discord.deb "https://discord.com/api/download?platform=linux&format=deb" && sudo dpkg -i discord.deb && mv discord.deb discord.old.deb; else sudo dpkg -i discord.old.deb && rm discord.old.deb; fi;
pnpm install && pnpm build && pnpm inject
find ~/.dotfiles/desktop/discord/themes -type f -exec ln -sf {} ~/.config/BetterDiscord/themes/ \;
wget https://discordstyles.github.io/DarkMatter/DarkMatter.theme.css -O ~/.config/BetterDiscord/themes/DarkMatter.theme.css
}
ytdlp() {
sudo apt-get install -y ffmpeg
yes | sudo add-apt-repository ppa:tomtomtom/yt-dlp # Add ppa repo to apt
sudo apt update # Update package list
sudo apt install -y yt-dlp # Install yt-dlp
}
signal() {
# 1. Install our official public software signing key:
wget -O- https://updates.signal.org/desktop/apt/keys.asc | gpg --dearmor > signal-desktop-keyring.gpg
cat signal-desktop-keyring.gpg | sudo tee /usr/share/keyrings/signal-desktop-keyring.gpg > /dev/null
# 2. Add our repository to your list of repositories:
echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/signal-desktop-keyring.gpg] https://updates.signal.org/desktop/apt xenial main' |\
sudo tee /etc/apt/sources.list.d/signal-xenial.list
# 3. Update your package database and install Signal:
sudo apt update && sudo apt install signal-desktop
}
### Networking etc
wireguard_client() {
sudo apt update && sudo apt install -y wireguard resolveconf
mkdir -p ~/wireguard && chmod 700 ~/wireguard
wg genkey | tee ~/wireguard/private.key
cat ~/wireguard/private.key | wg pubkey | tee ~/wireguard/public.key
echo "EXECUTE THE FOLLOWING ON THE VPS SERVER, then create a new client and copy the client config to ~/wireguard/wg0.conf\n--------------"
echo "curl -O https://raw.githubusercontent.com/angristan/wireguard-install/master/wireguard-install.sh
chmod +x wireguard-install.sh
./wireguard-install.sh"
echo "When done, execute (on the CLIENT):\nsudo wg-quick up ~/wireguard/wg0.conf"
}
sshkeys() {
ssh-keygen -t ed25519 -C "69987866+MaxWolf-01@users.noreply.github.com"
find ~/.ssh/ -type f -exec chmod 600 {} \; && find ~/.ssh/ -type d -exec chmod 700 {} \; && find ~/.ssh/ -type f -name "*.pub" -exec chmod 644 {} \;
ssh-add ~/.ssh/id_ed25519
cat ~/.ssh/id_ed25519.pub
echo "Put your public key on github -> settings -> SSH and GPG keys"
}
openconnect() {
sudo apt-get update && sudo apt-get install network-manager-openconnect network-manager-openconnect-gnome
sudo systemctl restart NetworkManager
}
nvidia_optimus() {
# TODO iGPU not used / display not working if hybrid / off
cd ~/repos/tools
if [ -d "envycontrol" ]; then cd envycontrol && git pull; else git clone --depth 1 https://github.com/bayasdev/envycontrol.git && cd envycontrol; fi;
sudo pip install .
# https://github.com/bayasdev/envycontrol/wiki/Frequently-Asked-Questions#instructions-for-ubuntu-and-its-derivatives
sudo prime-select on-demand
sudo systemctl mask gpu-manager.service
sudo apt-get install -y gnome-tweaks
echo "Install the gui manager according to gnome version @ https://github.com/LorenzoMorelli/GPU_profile_selector?tab=readme-ov-file#manual"
}
# Check if the first argument is the name of a function
if declare -f "$1" > /dev/null; then
# Call the function with the rest of the arguments
"$@"
else
echo "$1 is not a function"
fi