Skip to content

Add idempotent install.sh for dotfiles setup#3

Open
kai3769 wants to merge 2 commits intohiqsol:masterfrom
kai3769:kai/install-sh
Open

Add idempotent install.sh for dotfiles setup#3
kai3769 wants to merge 2 commits intohiqsol:masterfrom
kai3769:kai/install-sh

Conversation

@kai3769
Copy link
Copy Markdown
Contributor

@kai3769 kai3769 commented Mar 29, 2026

Summary

Single script to symlink dotfiles into $HOME and bootstrap fish plugins.

  • Relative symlinks (.config/...) — survive bind-mounts and home renames
  • Existing non-symlink files are skipped with a warning (never overwrites)
  • Fisher installed only if missing; plugins synced via fisher update
  • Requires bash 4+ (associative arrays)

What it links

.aliases, .profile, .shrc, .zshenv, .tmux.conf, bin — all 6 symlinks from the README.

Design decisions

  • Clone is a prerequisite (no auto-clone)
  • Relative paths only
  • No --dry-run for v1
  • fisher update over fisher install (handles removals)
  • Zsh plugins skipped for now (no plugin manager in repo)

Usage

~/.config/install.sh

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added installation script for automated dotfiles setup with validation, symlink management, and Fish shell plugin configuration.
  • Chores

    • Removed agentic.nvim plugin configuration and keybindings.

kai3769 and others added 2 commits March 25, 2026 04:30
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>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 29, 2026

📝 Walkthrough

Walkthrough

This 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

Cohort / File(s) Summary
Dotfiles Installation Script
install.sh
New bash script implementing idempotent dotfiles installation: validates repo structure (git/ and fish/config.fish), manages home directory symlinks via associative array mapping, and conditionally installs and updates Fisher plugin manager.
Neovim Plugin Removal
nvim/lua/plugins/agentic.lua
Deleted plugin specification for agentic.nvim, removing Gemini provider configuration and all associated keybindings for chat toggling, context management, and session control.

Sequence Diagram

sequenceDiagram
    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
Loading

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested Reviewers

  • hiqsol

Poem

🐰✨ A script to link our dotfiles true,
And fisher's grip so strong and new—
No more agentic whispers sail,
Just symlinks, steady, none shall fail!
The warren's tools dance, clean and bright! 🌟

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add idempotent install.sh for dotfiles setup' directly and clearly summarizes the main change: adding a new install.sh script for dotfiles installation. It accurately reflects the primary addition in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 source with -sL flags, which silences both progress and error output. This can mask HTTP or transfer failures, allowing potentially incomplete scripts to execute.

Add --fail to fail on HTTP errors, --show-error to 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

📥 Commits

Reviewing files that changed from the base of the PR and between f5da76b and 3fed7a0.

📒 Files selected for processing (2)
  • install.sh
  • nvim/lua/plugins/agentic.lua
💤 Files with no reviewable changes (1)
  • nvim/lua/plugins/agentic.lua

Comment on lines +6 to +7
DOTDIR="${XDG_CONFIG_HOME:-$HOME/.config}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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=(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 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" || true

Repository: hiqsol/dotfiles

Length of output: 140


🏁 Script executed:

head -30 install.sh

Repository: 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.

Suggested change
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant