Browse Source

fix(scripts): make install.sh cross-platform (Linux/macOS/Windows Git Bash)

- Add Windows detection via uname -s (MINGW/MSYS/CYGWIN)
- Wrap chmod +x in make_executable() — no-op on NTFS, runs normally on Unix
- Update header and usage comment to reflect Git Bash support
- Simplify README install section: single bash command works everywhere
  (PowerShell install.ps1 remains as an alternative)
0xDarkMatter 4 weeks ago
parent
commit
f371f57d59
2 changed files with 21 additions and 14 deletions
  1. 2 8
      README.md
  2. 19 6
      scripts/install.sh

+ 2 - 8
README.md

@@ -169,19 +169,13 @@ This installs globally (available in all projects). Toggle on/off with `/plugin`
 
 ### Script Install
 
-**Linux/macOS:**
 ```bash
 git clone https://github.com/0xDarkMatter/claude-mods.git
 cd claude-mods
-./scripts/install.sh
+bash scripts/install.sh
 ```
 
-**Windows (PowerShell):**
-```powershell
-git clone https://github.com/0xDarkMatter/claude-mods.git
-cd claude-mods
-.\scripts\install.ps1
-```
+Works on Linux, macOS, and Windows (Git Bash). A PowerShell alternative is also available at `scripts/install.ps1`.
 
 The install scripts:
 - Copy commands, skills, agents, rules, output styles to `~/.claude/`

+ 19 - 6
scripts/install.sh

@@ -1,10 +1,12 @@
 #!/usr/bin/env bash
 #
-# claude-mods Installer (Linux/macOS)
+# claude-mods Installer (Linux / macOS / Windows Git Bash)
 # Copies commands, skills, agents, and rules to ~/.claude/
 # Handles cleanup of deprecated items and command-to-skill migrations.
 #
-# Usage: ./scripts/install.sh
+# Usage:
+#   Linux/macOS:       ./scripts/install.sh
+#   Windows Git Bash:  bash scripts/install.sh
 
 set -e
 
@@ -15,7 +17,7 @@ RED='\033[0;31m'
 NC='\033[0m'
 
 echo -e "${BLUE}╔══════════════════════════════════════════════════════════════╗${NC}"
-echo -e "${BLUE}║           claude-mods Installer (Unix)                       ║${NC}"
+echo -e "${BLUE}║     claude-mods Installer (Linux / macOS / Git Bash)         ║${NC}"
 echo -e "${BLUE}╚══════════════════════════════════════════════════════════════╝${NC}"
 echo ""
 
@@ -23,6 +25,17 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
 PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
 CLAUDE_DIR="$HOME/.claude"
 
+# Detect Windows (Git Bash / MINGW / MSYS) — chmod is a no-op on NTFS
+IS_WINDOWS=false
+case "$(uname -s)" in
+    MINGW*|MSYS*|CYGWIN*) IS_WINDOWS=true ;;
+esac
+
+# Wrapper: chmod is meaningful only on Unix
+make_executable() {
+    $IS_WINDOWS || chmod +x "$1"
+}
+
 # Ensure ~/.claude directories exist
 for dir in commands skills agents rules output-styles; do
     mkdir -p "$CLAUDE_DIR/$dir"
@@ -179,12 +192,12 @@ fi
 mkdir -p "$CLAUDE_DIR/pigeon"
 if [ -f "$PROJECT_ROOT/skills/pigeon/scripts/mail-db.sh" ]; then
     cp "$PROJECT_ROOT/skills/pigeon/scripts/mail-db.sh" "$CLAUDE_DIR/pigeon/"
-    chmod +x "$CLAUDE_DIR/pigeon/mail-db.sh"
+    make_executable "$CLAUDE_DIR/pigeon/mail-db.sh"
     echo -e "  ${GREEN}mail-db.sh${NC}"
 fi
 if [ -f "$PROJECT_ROOT/hooks/check-mail.sh" ]; then
     cp "$PROJECT_ROOT/hooks/check-mail.sh" "$CLAUDE_DIR/pigeon/"
-    chmod +x "$CLAUDE_DIR/pigeon/check-mail.sh"
+    make_executable "$CLAUDE_DIR/pigeon/check-mail.sh"
     echo -e "  ${GREEN}check-mail.sh${NC}"
 fi
 
@@ -225,7 +238,7 @@ mkdir -p "$CLAUDE_DIR/auto-skill"
 for script in track-tools.sh evaluate.sh; do
     if [ -f "$PROJECT_ROOT/skills/auto-skill/scripts/$script" ]; then
         cp "$PROJECT_ROOT/skills/auto-skill/scripts/$script" "$CLAUDE_DIR/auto-skill/"
-        chmod +x "$CLAUDE_DIR/auto-skill/$script"
+        make_executable "$CLAUDE_DIR/auto-skill/$script"
         echo -e "  ${GREEN}$script${NC}"
     fi
 done