Add drunkendotfiles installer and rewrite README
install.sh: curl-pipe installer that clones to ~/.yadr, runs YADR's native rake install, then layers personal dotfiles on top of $HOME with backups on collision. README.md: replace YADR's upstream readme with drunkendotfiles- specific usage docs, credit, and refresh-from-upstream instructions.
This commit is contained in:
129
install.sh
Normal file → Executable file
129
install.sh
Normal file → Executable file
@@ -1,11 +1,124 @@
|
||||
#!/bin/sh
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# drunkendotfiles installer
|
||||
#
|
||||
# Usage:
|
||||
# curl -fsSL https://gitea.dlw.la/dissimulo/drunkendotfiles/raw/branch/drunkendotfiles/install.sh | bash
|
||||
#
|
||||
# Or clone first and run locally:
|
||||
# git clone https://gitea.dlw.la/dissimulo/drunkendotfiles.git ~/.yadr && ~/.yadr/install.sh
|
||||
#
|
||||
|
||||
if [ ! -d "$HOME/.yadr" ]; then
|
||||
echo "Installing YADR for the first time"
|
||||
git clone --depth=1 https://github.com/skwp/dotfiles.git "$HOME/.yadr"
|
||||
cd "$HOME/.yadr"
|
||||
[ "$1" = "ask" ] && export ASK="true"
|
||||
rake install
|
||||
set -euo pipefail
|
||||
|
||||
REPO_URL="${DRUNKENDOTFILES_REPO:-https://gitea.dlw.la/dissimulo/drunkendotfiles.git}"
|
||||
YADR_DIR="$HOME/.yadr"
|
||||
BACKUP_DIR="$HOME/.drunkendotfiles.bak.$(date +%Y%m%d-%H%M%S)"
|
||||
|
||||
# Files at the repo root (relative to $YADR_DIR) that get placed at $HOME/<file>.
|
||||
# Includes real files, relative symlinks into .yadr, and .backup copies.
|
||||
PERSONAL_FILES=(
|
||||
.bash_logout .bashrc .fehbg .gopherrc .jigdo-lite .nanorc .profile
|
||||
.rainbow_config.json .selected_editor .tmux.conf .weatherspect .xmodmap
|
||||
.xscreensaver .xsnowrc
|
||||
.zlogin.backup .zlogout.backup .zpreztorc.backup .zprofile.backup
|
||||
.zshenv.backup .zshrc.backup
|
||||
# Relative symlinks into .yadr/... — YADR's rake install creates equivalents,
|
||||
# but we deploy these too so things work even if rake install is skipped.
|
||||
.aprc .ctags .editrc .escaped_colors.rb .gemrc .gitconfig .inputrc .pryrc
|
||||
.rdebugrc .unescaped_colors.rb .vim .vimrc .zlogin .zlogout .zpreztorc
|
||||
.zprofile .zshenv .zshrc
|
||||
)
|
||||
|
||||
# Directories deployed wholesale to $HOME/<dir>/.
|
||||
PERSONAL_DIRS=(
|
||||
.fonts .irssi .nano .themes .local .mplayer
|
||||
)
|
||||
|
||||
have() { command -v "$1" >/dev/null 2>&1; }
|
||||
|
||||
log() { printf '==> %s\n' "$*"; }
|
||||
info() { printf ' %s\n' "$*"; }
|
||||
warn() { printf '!! %s\n' "$*" >&2; }
|
||||
|
||||
require() {
|
||||
have "$1" || { warn "missing required command: $1"; exit 1; }
|
||||
}
|
||||
|
||||
require git
|
||||
|
||||
log "drunkendotfiles installer"
|
||||
log "repo: $REPO_URL"
|
||||
log "target: $YADR_DIR"
|
||||
log "backup: $BACKUP_DIR (created on first collision)"
|
||||
echo
|
||||
|
||||
# 1. Fetch the repo into $HOME/.yadr
|
||||
if [ -d "$YADR_DIR/.git" ]; then
|
||||
log "Repo already cloned — pulling latest"
|
||||
git -C "$YADR_DIR" pull --ff-only
|
||||
elif [ -d "$YADR_DIR" ]; then
|
||||
warn "$YADR_DIR exists but isn't a git repo. Refusing to overwrite."
|
||||
exit 1
|
||||
else
|
||||
echo "YADR is already installed"
|
||||
log "Cloning drunkendotfiles"
|
||||
git clone --depth=1 "$REPO_URL" "$YADR_DIR"
|
||||
fi
|
||||
|
||||
cd "$YADR_DIR"
|
||||
|
||||
# 2. Run YADR's native install (Vim plugins, prezto, etc.)
|
||||
if have rake; then
|
||||
log "Running YADR rake install"
|
||||
[ "${1:-}" = "ask" ] && export ASK="true"
|
||||
rake install || warn "rake install returned non-zero; continuing"
|
||||
else
|
||||
warn "rake not found — skipping YADR rake install. Install ruby+rake and re-run this script to finish YADR setup."
|
||||
fi
|
||||
|
||||
# 3. Deploy personal dotfiles
|
||||
backup_one() {
|
||||
local src_name="$1"
|
||||
local dst="$HOME/$src_name"
|
||||
if [ -e "$dst" ] || [ -L "$dst" ]; then
|
||||
mkdir -p "$BACKUP_DIR/$(dirname "$src_name")"
|
||||
mv "$dst" "$BACKUP_DIR/$src_name"
|
||||
fi
|
||||
}
|
||||
|
||||
deploy_one() {
|
||||
local name="$1"
|
||||
local src="$YADR_DIR/$name"
|
||||
local dst="$HOME/$name"
|
||||
if [ ! -e "$src" ] && [ ! -L "$src" ]; then
|
||||
return
|
||||
fi
|
||||
backup_one "$name"
|
||||
mkdir -p "$(dirname "$dst")"
|
||||
cp -a "$src" "$dst"
|
||||
info "$name"
|
||||
}
|
||||
|
||||
log "Deploying personal dotfiles"
|
||||
for f in "${PERSONAL_FILES[@]}"; do deploy_one "$f"; done
|
||||
for d in "${PERSONAL_DIRS[@]}"; do deploy_one "$d"; done
|
||||
|
||||
# .local/bin/claude is a relative symlink to ../share/claude/versions/...
|
||||
# If that target isn't present on this machine, remove the dangling link.
|
||||
if [ -L "$HOME/.local/bin/claude" ] && [ ! -e "$HOME/.local/bin/claude" ]; then
|
||||
rm "$HOME/.local/bin/claude"
|
||||
info "(skipped .local/bin/claude: target not present on this machine)"
|
||||
fi
|
||||
|
||||
# Ensure +x on user scripts
|
||||
if [ -d "$HOME/.local/bin" ]; then
|
||||
find "$HOME/.local/bin" -maxdepth 1 -type f -exec chmod +x {} \; 2>/dev/null || true
|
||||
fi
|
||||
|
||||
echo
|
||||
log "Done."
|
||||
if [ -d "$BACKUP_DIR" ]; then
|
||||
info "Files that would have been overwritten are backed up at:"
|
||||
info " $BACKUP_DIR"
|
||||
fi
|
||||
info "Log out and back in (or start a new shell) to pick up the new configs."
|
||||
|
||||
Reference in New Issue
Block a user