Dotfiles/setup/modules/shell-setup.sh

131 lines
3.6 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
source "$(dirname "${BASH_SOURCE[0]}")/lib/logging.sh"
log "Updating system..."
sudo pacman -Syu --noconfirm
log "Installing base shell packages..."
PACKAGES=(zsh neovim curl pyright bash atftp bash-language-server btop clang fastfetch fzf hyfetch lua-language-server micro nano pulsemixer yazi z qrencode distrobox dysk python python-pip glow notmuch alot)
for pkg in "${PACKAGES[@]}"; do
if ! pacman -Qi "$pkg" &>/dev/null; then
log "Installing $pkg..."
sudo pacman -S --noconfirm --needed "$pkg"
else
skip "$pkg already installed."
fi
done
# abook (AUR)
if ! command -v abook &>/dev/null; then
log "Installing abook (AUR)..."
yay -S --noconfirm --needed abook
else
skip "abook already installed."
fi
# yay
if ! command -v yay &>/dev/null; then
log "Installing yay..."
sudo pacman -S --noconfirm --needed git base-devel
git clone https://aur.archlinux.org/yay.git /tmp/yay
cd /tmp/yay && makepkg -si --noconfirm
cd ~
else
skip "yay already installed."
fi
# Rust / Cargo
if ! command -v cargo &>/dev/null; then
log "Installing Rust & Cargo..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
. "$HOME/.cargo/env"
else
skip "Rust & Cargo already installed."
fi
# nvm + Node.js
if ! command -v node &>/dev/null; then
log "Installing nvm and Node.js..."
if [ ! -d "$HOME/.nvm" ]; then
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh | bash
fi
. "$HOME/.nvm/nvm.sh"
nvm install 22
else
skip "Node.js already installed."
fi
log "Configuring git..."
git config --global core.editor nvim
log "Deploying dotfiles..."
mkdir -p ~/.config ~/Pictures
ln -sf ~/Dotfiles/.bashrc ~/.bashrc
ln -sf ~/Dotfiles/.zshrc ~/.zshrc
ln -sf ~/Dotfiles/starship.toml ~/.config/starship.toml
rm -rf ~/.config/micro
cp -r ~/Dotfiles/micro ~/.config/
rm -rf ~/.config/nvim
ln -sf ~/Dotfiles/nvim ~/.config/nvim
log "Syncing neovim plugins (lazy.nvim)..."
nvim --headless "+Lazy! sync" +qa 2>/dev/null || true
rm -rf ~/.config/alot
ln -sf ~/Dotfiles/alot ~/.config/alot
rm -rf ~/.config/yazi
ln -sf ~/Dotfiles/yazi ~/.config/yazi
rm -rf ~/.config/spotify-tui
ln -sf ~/Dotfiles/spotify-tui ~/.config/spotify-tui
cp -f ~/Dotfiles/resources/fflogo.svg ~/Pictures/fflogo.svg
# Starship
if ! command -v starship &>/dev/null; then
log "Installing Starship..."
curl -sS https://starship.rs/install.sh | sh -s -- --yes
else
skip "Starship already installed."
fi
# oh-my-zsh
if [ ! -d "$HOME/.oh-my-zsh" ]; then
log "Installing oh-my-zsh..."
RUNZSH=no CHSH=no sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
else
skip "oh-my-zsh already installed."
fi
# oh-my-zsh plugins
ZSH_CUSTOM="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}"
if [ ! -d "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting" ]; then
log "Installing zsh-syntax-highlighting..."
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git \
"$ZSH_CUSTOM/plugins/zsh-syntax-highlighting"
else
skip "zsh-syntax-highlighting already installed."
fi
if [ ! -d "$ZSH_CUSTOM/plugins/zsh-autosuggestions" ]; then
log "Installing zsh-autosuggestions..."
git clone https://github.com/zsh-users/zsh-autosuggestions \
"$ZSH_CUSTOM/plugins/zsh-autosuggestions"
else
skip "zsh-autosuggestions already installed."
fi
# Default shell
if [ "$SHELL" != "/usr/bin/zsh" ]; then
log "Setting zsh as default shell..."
chsh -s /usr/bin/zsh
else
skip "zsh is already the default shell."
fi
log "Shell setup complete."