Files
dotfiles/bootstrap.sh
jsarthak f96891b6ec refactor: consolidate all branches into single-branch Strategy 1
- bash/.bashrc: replace oh-my-bash with minimal unified config
  sources common → aliases → OS overlay → .bashrc.local

- zsh/.zshrc: remove hardcoded macOS PATHs (moved to macos overlay)
  clean sourcing order: common → personal → aliases → OS → .zshrc.local

- shell/common: populated with universal exports (EDITOR, HISTSIZE, etc.)
- shell/macos: Homebrew, Antigravity, Flutter PATH, fzf init, macOS aliases
- shell/linux: xdg-open, xclip, fzf init for Linux

- nvim/plugins/work.lua: Copilot plugin (migrated from origin/work branch)
- nvim/plugins/_init.lua: conditional load via DOTFILES_PROFILE=work env var

- tmux/.tmux.conf.local: per-machine override hook (~/.tmux.conf.machine.local)

- bootstrap.sh: one-command new machine setup with profile support
  usage: bash bootstrap.sh [personal|work]

- .gitignore: comprehensive .local file ignore patterns

All branches (linux, mac, work, linux_personal, linux_work, mac_personal)
can now be deleted — all unique content is merged into master.
2026-07-18 14:38:41 +05:30

86 lines
4.2 KiB
Bash

#!/usr/bin/env bash
# bootstrap.sh — Set up dotfiles on a new machine
# Usage: bash bootstrap.sh [--profile personal|work]
#
# This script stows all dotfile packages, copies shell config files,
# and creates untracked .local stub files for per-machine overrides.
set -e
DOTFILES_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROFILE="${1:-personal}"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " Dotfiles Bootstrap"
echo " Profile : $PROFILE"
echo " OS : $(uname -s)"
echo " Host : $(hostname)"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
# ── 1. Stow all packages ───────────────────────────────────────────────────────
# shell is excluded from global .stow-local-ignore, handled separately below
PACKAGES="zsh bash tmux nvim starship alacritty kitty ghostty wezterm zed btop vim"
for pkg in $PACKAGES; do
if [[ -d "$DOTFILES_DIR/$pkg" ]]; then
echo " stow → $pkg"
stow --adopt --dir="$DOTFILES_DIR" --target="$HOME" "$pkg" 2>/dev/null || \
echo " ⚠ stow $pkg skipped (already linked or conflict)"
fi
done
# ── 2. Copy shell config files manually (stow-local-ignore excludes `shell`) ──
SHELL_SRC="$DOTFILES_DIR/shell/.config/shell"
SHELL_DST="$HOME/.config/shell"
mkdir -p "$SHELL_DST"
for f in common aliases personal work macos linux; do
if [[ -f "$SHELL_SRC/$f" ]]; then
echo " copy shell/$f$SHELL_DST/$f"
cp -n "$SHELL_SRC/$f" "$SHELL_DST/$f" 2>/dev/null || true
fi
done
# ── 3. Create untracked .local stub files ─────────────────────────────────────
create_stub() {
local file="$1" comment="$2"
if [[ ! -f "$file" ]]; then
echo "# $comment" > "$file"
echo " created stub → $file"
else
echo " exists (skipped) → $file"
fi
}
create_stub "$HOME/.zshrc.local" "Per-machine zsh overrides — never committed"
create_stub "$HOME/.bashrc.local" "Per-machine bash overrides — never committed"
create_stub "$HOME/.tmux.conf.machine.local" "Per-machine tmux overrides — never committed"
create_stub "$HOME/.gitconfig.local" "Per-machine git identity — never committed"
# ── 4. Inject profile into .zshrc.local if requested ──────────────────────────
if [[ "$PROFILE" == "work" ]]; then
if ! grep -q "DOTFILES_PROFILE" "$HOME/.zshrc.local" 2>/dev/null; then
echo "" >> "$HOME/.zshrc.local"
echo "# Work profile — load work-specific shell config and nvim plugins" >> "$HOME/.zshrc.local"
echo "export DOTFILES_PROFILE=work" >> "$HOME/.zshrc.local"
echo "source ~/.config/shell/work" >> "$HOME/.zshrc.local"
echo " → injected DOTFILES_PROFILE=work into ~/.zshrc.local"
fi
fi
# ── 5. macOS-specific setup ───────────────────────────────────────────────────
if [[ "$(uname -s)" == "Darwin" ]]; then
# Install Homebrew if missing
if ! command -v brew >/dev/null 2>&1; then
echo " Installing Homebrew…"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
fi
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " Done! Next steps:"
echo " 1. Edit ~/.zshrc.local — add secrets / tokens"
echo " 2. Edit ~/.gitconfig.local — add your git identity for this machine"
echo " 3. Run: exec zsh (or source ~/.bashrc for bash)"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"