Add idempotent install.sh for dotfiles setup#3
Add idempotent install.sh for dotfiles setup#3kai3769 wants to merge 2 commits intohiqsol:masterfrom
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Single script to symlink dotfiles into $HOME and bootstrap fish plugins. - Relative symlinks (.config/...) survive bind-mounts - Existing non-symlink files are skipped with a warning - Fisher installed only if missing, plugins synced via `fisher update` - Requires bash 4+ for associative arrays Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis PR introduces a new idempotent bash installation script for managing dotfiles and removes the agentic.nvim plugin configuration. The install script validates the dotfiles repository structure, creates or repairs symlinks in the home directory, and sets up Fish shell tooling including the fisher plugin manager. Changes
Sequence DiagramsequenceDiagram
participant User
participant InstallScript as install.sh
participant FileSystem as Filesystem
participant FishShell as Fish Shell
participant Fisher as Fisher
User->>InstallScript: Execute script
InstallScript->>FileSystem: Check for $DOTDIR/git directory
FileSystem-->>InstallScript: Directory status
InstallScript->>FileSystem: Check for $DOTDIR/fish/config.fish
FileSystem-->>InstallScript: File status
rect rgba(100, 150, 200, 0.5)
note right of InstallScript: Validation failed or passed
end
InstallScript->>FileSystem: Read symlink mappings
FileSystem-->>InstallScript: Mapping config
loop For each symlink entry
InstallScript->>FileSystem: Check if target exists
alt Target exists and is non-symlink
InstallScript->>InstallScript: Skip (log message)
else Target exists but wrong symlink
InstallScript->>FileSystem: Remove incorrect symlink
InstallScript->>FileSystem: Create correct symlink
else Target missing
InstallScript->>FileSystem: Create new symlink
end
end
rect rgba(150, 200, 100, 0.5)
note right of InstallScript: Symlink setup complete
end
alt Fish shell available
InstallScript->>FishShell: Check if fisher installed
FishShell-->>InstallScript: Fisher status
alt Fisher missing
InstallScript->>Fisher: Install fisher
Fisher-->>InstallScript: Installed
end
alt fish_plugins manifest exists
InstallScript->>Fisher: Run fisher update
Fisher-->>InstallScript: Plugins synced
end
end
InstallScript-->>User: Installation complete
Estimated Code Review Effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested Reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
install.sh (1)
56-56: Harden Fisher bootstrap curl flags for fail-fast behavior.Line 56 pipes a curl response directly into
sourcewith-sLflags, which silences both progress and error output. This can mask HTTP or transfer failures, allowing potentially incomplete scripts to execute.Add
--failto fail on HTTP errors,--show-errorto display errors despite silent mode, and timeouts (--connect-timeout 10 --max-time 60) to prevent indefinite hangs:Suggested hardening
- fish -c "curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher install jorgebucaran/fisher" + fish -c "curl --fail --show-error --location --connect-timeout 10 --max-time 60 https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher install jorgebucaran/fisher"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@install.sh` at line 56, The curl invocation that pipes into source (the line starting with fish -c "curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher install jorgebucaran/fisher") must be hardened: keep -sL but add --fail and --show-error and timeouts like --connect-timeout 10 --max-time 60 so the command fails fast and surfaces HTTP/transfer errors before sourcing; update that exact command string accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@install.sh`:
- Around line 6-7: The install script sets
DOTDIR="${XDG_CONFIG_HOME:-$HOME/.config}" but later hardcodes ~/.config when
creating symlinks, causing broken links if XDG_CONFIG_HOME differs; update the
symlink creation to reference the DOTDIR variable (e.g., use "$DOTDIR/..."
instead of "~/.config/...") and ensure any parent directories under "$DOTDIR"
are created before linking so links point to the actual XDG path; search for
usages of DOTDIR and the hardcoded ".config" in install.sh to replace and add
mkdir -p for the target directories.
- Line 17: Add a Bash version guard before using associative arrays: detect the
running shell's version (e.g., via BASH_VERSINFO or BASH_VERSION) near the top
of the script (around where you currently plan to declare associative arrays)
and exit with a clear error message if the major version is less than 4 so that
the later use of declare -A will not fail at runtime; reference the use of
declare -A and the associative array LINKS in your check and ensure the script
returns non-zero on failure.
---
Nitpick comments:
In `@install.sh`:
- Line 56: The curl invocation that pipes into source (the line starting with
fish -c "curl -sL
https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish
| source && fisher install jorgebucaran/fisher") must be hardened: keep -sL but
add --fail and --show-error and timeouts like --connect-timeout 10 --max-time 60
so the command fails fast and surfaces HTTP/transfer errors before sourcing;
update that exact command string accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 9bbb2766-2663-4d0a-81fb-60ac1b571016
📒 Files selected for processing (2)
install.shnvim/lua/plugins/agentic.lua
💤 Files with no reviewable changes (1)
- nvim/lua/plugins/agentic.lua
| DOTDIR="${XDG_CONFIG_HOME:-$HOME/.config}" | ||
|
|
There was a problem hiding this comment.
XDG path handling is inconsistent and can produce broken symlinks.
Line 6 allows custom XDG_CONFIG_HOME, but Line 29 always links to .config/.... If XDG_CONFIG_HOME is not $HOME/.config, created links point to the wrong location.
💡 Suggested fix
DOTDIR="${XDG_CONFIG_HOME:-$HOME/.config}"
+if [[ "$DOTDIR" != "$HOME/"* ]]; then
+ echo "ERROR: XDG_CONFIG_HOME must be under \$HOME for relative symlinks: $DOTDIR"
+ exit 1
+fi
+DOTDIR_REL="${DOTDIR#$HOME/}"
@@
- source=".config/${LINKS[$name]}"
+ source="${DOTDIR_REL}/${LINKS[$name]}"Also applies to: 29-29
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@install.sh` around lines 6 - 7, The install script sets
DOTDIR="${XDG_CONFIG_HOME:-$HOME/.config}" but later hardcodes ~/.config when
creating symlinks, causing broken links if XDG_CONFIG_HOME differs; update the
symlink creation to reference the DOTDIR variable (e.g., use "$DOTDIR/..."
instead of "~/.config/...") and ensure any parent directories under "$DOTDIR"
are created before linking so links point to the actual XDG path; search for
usages of DOTDIR and the hardcoded ".config" in install.sh to replace and add
mkdir -p for the target directories.
|
|
||
| # ── 2. Home-directory symlinks ────────────────────────────────── | ||
| # Each entry: target (relative to $HOME) → source (relative to $DOTDIR) | ||
| declare -A LINKS=( |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
file="install.sh"
echo "[1] associative array usage"
rg -n 'declare\s+-A' "$file"
echo "[2] explicit Bash version guard"
rg -n 'BASH_VERSINFO|requires Bash 4\+' "$file" || trueRepository: hiqsol/dotfiles
Length of output: 140
🏁 Script executed:
head -30 install.shRepository: hiqsol/dotfiles
Length of output: 1030
Add a Bash 4+ version guard before using associative arrays.
Line 17 uses declare -A, which fails on Bash 3.x. Add an explicit version check near line 4 to catch this before runtime.
Suggested fix
set -euo pipefail
+
+if (( BASH_VERSINFO[0] < 4 )); then
+ echo "ERROR: install.sh requires Bash 4+ (found ${BASH_VERSINFO[0]}.${BASH_VERSINFO[1]})."
+ exit 1
+fi📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| declare -A LINKS=( | |
| set -euo pipefail | |
| if (( BASH_VERSINFO[0] < 4 )); then | |
| echo "ERROR: install.sh requires Bash 4+ (found ${BASH_VERSINFO[0]}.${BASH_VERSINFO[1]})." | |
| exit 1 | |
| fi | |
| declare -A LINKS=( |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@install.sh` at line 17, Add a Bash version guard before using associative
arrays: detect the running shell's version (e.g., via BASH_VERSINFO or
BASH_VERSION) near the top of the script (around where you currently plan to
declare associative arrays) and exit with a clear error message if the major
version is less than 4 so that the later use of declare -A will not fail at
runtime; reference the use of declare -A and the associative array LINKS in your
check and ensure the script returns non-zero on failure.
Summary
Single script to symlink dotfiles into
$HOMEand bootstrap fish plugins..config/...) — survive bind-mounts and home renamesfisher updateWhat it links
.aliases,.profile,.shrc,.zshenv,.tmux.conf,bin— all 6 symlinks from the README.Design decisions
--dry-runfor v1fisher updateoverfisher install(handles removals)Usage
~/.config/install.sh🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Chores