This commit is contained in:
2026-04-21 15:25:14 +00:00
parent b88c09db08
commit 10909bc66f

176
part1.sh
View File

@@ -1,50 +1,154 @@
#!/bin/bash #!/bin/bash
set -euo pipefail
cd ~ # -------------------------------
# Update system # Helpers
sudo pacman -Syu # -------------------------------
info() {
printf '\n==> %s\n' "$1"
}
# Install base utils append_if_missing() {
sudo pacman -S --needed git which base-devel local line="$1"
local file="$2"
touch "$file"
grep -qxF "$line" "$file" || echo "$line" >>"$file"
}
# Install yay # -------------------------------
git clone https://aur.archlinux.org/yay.git # Paths and config
cd yay # -------------------------------
makepkg -si HOME_DIR="$HOME"
cd ~ BASHRC="$HOME_DIR/.bashrc"
rm -rf yay SSH_KEY_PATH="$HOME_DIR/.ssh/id_ed25519"
SSH_KEY_EMAIL="hector@h3cx.dev"
DOTFILES_REPO="gitea@git.h3cx.dev:h3cx/HectorsDotFiles.git"
WALLPAPERS_REPO="gitea@git.h3cx.dev:h3cx/HectorsWallpapers.git"
CONFIG_BACKUP="$HOME_DIR/.config.backup.$(date +%Y%m%d-%H%M%S)"
WALLPAPER_TARGET="$HOME_DIR/.local/share/wallpapers"
TMP_DIR="$(mktemp -d)"
# Install zen-browser cleanup() {
yay -S zen-browser-bin rm -rf "$TMP_DIR"
}
trap cleanup EXIT
# Install font cd "$HOME_DIR"
sudo pacman -S ttf-jetbrains-mono-nerd
# Install clipboard # -------------------------------
sudo pacman -S cliphist wl-clipboard # System update and packages
# -------------------------------
info "Updating system"
sudo pacman -Syu --noconfirm
# Install nvim info "Installing base packages"
sudo pacman -S nvim sudo pacman -S --needed --noconfirm \
git \
which \
base-devel \
ttf-jetbrains-mono-nerd \
cliphist \
wl-clipboard \
neovim \
starship \
lazygit \
openssh
# Install ble.sh # -------------------------------
git clone --recursive --depth 1 --shallow-submodules https://github.com/akinomyoga/ble.sh.git # yay
make -C ble.sh install PREFIX=~/.local # -------------------------------
echo 'source -- ~/.local/share/blesh/ble.sh' >>~/.bashrc if ! command -v yay >/dev/null 2>&1; then
cd ~ info "Installing yay"
rm -rf ble.sh git clone https://aur.archlinux.org/yay.git "$TMP_DIR/yay"
(
cd "$TMP_DIR/yay"
makepkg -si --noconfirm
)
else
info "yay already installed"
fi
# Install starship # -------------------------------
sudo pacman -S starship # AUR packages
grep -qxF 'eval "$(starship init bash)"' ~/.bashrc || echo 'eval "$(starship init bash)"' >>~/.bashrc # -------------------------------
source ~/.bashrc info "Installing AUR packages"
stty sane yay -S --needed --noconfirm zen-browser-bin
# Install lazygit # -------------------------------
sudo pacman -S lazygit # ble.sh
# -------------------------------
if [ ! -f "$HOME_DIR/.local/share/blesh/ble.sh" ]; then
info "Installing ble.sh"
git clone --recursive --depth 1 --shallow-submodules https://github.com/akinomyoga/ble.sh.git "$TMP_DIR/ble.sh"
make -C "$TMP_DIR/ble.sh" install PREFIX="$HOME_DIR/.local"
else
info "ble.sh already installed"
fi
append_if_missing 'source -- ~/.local/share/blesh/ble.sh' "$BASHRC"
# Setup git # -------------------------------
git config --global user.email "hector@h3cx.dev" # Shell setup
# -------------------------------
info "Configuring shell"
append_if_missing 'eval "$(starship init bash)"' "$BASHRC"
stty sane || true
# -------------------------------
# Git setup
# -------------------------------
info "Configuring git"
git config --global user.email "$SSH_KEY_EMAIL"
git config --global user.name "Hector van der Aa" git config --global user.name "Hector van der Aa"
# Generate ssh-keys # -------------------------------
ssh-keygen # SSH key setup for Gitea
# -------------------------------
info "Preparing SSH key for git access"
mkdir -p "$HOME_DIR/.ssh"
chmod 700 "$HOME_DIR/.ssh"
if [ ! -f "$SSH_KEY_PATH" ]; then
ssh-keygen -t ed25519 -C "$SSH_KEY_EMAIL" -f "$SSH_KEY_PATH" -N ""
else
info "SSH key already exists at $SSH_KEY_PATH, reusing it"
fi
chmod 600 "$SSH_KEY_PATH"
chmod 644 "$SSH_KEY_PATH.pub"
if command -v ssh-keyscan >/dev/null 2>&1; then
touch "$HOME_DIR/.ssh/known_hosts"
ssh-keyscan -H git.h3cx.dev >>"$HOME_DIR/.ssh/known_hosts" 2>/dev/null || true
fi
if command -v wl-copy >/dev/null 2>&1; then
wl-copy <"$SSH_KEY_PATH.pub"
info "Your public SSH key has been copied to the clipboard"
else
info "wl-copy not found, public key is below"
cat "$SSH_KEY_PATH.pub"
fi
echo
echo "Add this SSH public key as an authorized key in your Gitea account:"
echo " $SSH_KEY_PATH.pub"
echo
read -rp "Press Enter once the key has been added to git.h3cx.dev... "
# -------------------------------
# Clone private repositories
# -------------------------------
info "Replacing ~/.config with HectorsDotFiles"
if [ -d "$HOME_DIR/.config" ]; then
mv "$HOME_DIR/.config" "$CONFIG_BACKUP"
info "Existing ~/.config moved to $CONFIG_BACKUP"
fi
git clone "$DOTFILES_REPO" "$HOME_DIR/.config"
info "Installing wallpapers repository"
mkdir -p "$HOME_DIR/.local/share"
rm -rf "$WALLPAPER_TARGET"
git clone "$WALLPAPERS_REPO" "$WALLPAPER_TARGET"
info "Post-install section completed"
echo "You may want to restart your shell or run: source ~/.bashrc"