Fix installation scripts for non-interactive mode (piped from curl/iwr)

- Detect when stdin is not a terminal (piped input)
- Default to option 1 (skill-creator) in non-interactive mode
- Show helpful message about downloading for interactive use
- Prevents 'Invalid choice\!' error when piped from curl/iwr

This fixes the issue when users run:
  curl -fsSL https://...install.sh | bash
  iwr -useb https://...install.ps1 | iex

Tested with: echo "" | bash scripts/install.sh
This commit is contained in:
daymade
2025-10-24 18:32:05 +08:00
parent fd94d1b62e
commit 920d4afb6e
2 changed files with 60 additions and 20 deletions

View File

@@ -41,15 +41,29 @@ if (-not (Get-Command claude -ErrorAction SilentlyContinue)) {
Write-Host ""
}
# Installation menu
Write-Host "What would you like to install?"
Write-Host ""
Write-Host "1) skill-creator only (RECOMMENDED - enables you to create your own skills)"
Write-Host "2) All skills"
Write-Host "3) Custom selection"
Write-Host "4) Exit"
Write-Host ""
$choice = Read-Host "Enter your choice (1-4)"
# Check if running interactively
$isInteractive = [Environment]::UserInteractive -and -not [Console]::IsInputRedirected
if ($isInteractive) {
# Installation menu
Write-Host "What would you like to install?"
Write-Host ""
Write-Host "1) skill-creator only (RECOMMENDED - enables you to create your own skills)"
Write-Host "2) All skills"
Write-Host "3) Custom selection"
Write-Host "4) Exit"
Write-Host ""
$choice = Read-Host "Enter your choice (1-4)"
} else {
Write-Info "Running in non-interactive mode."
Write-Host "Defaulting to option 1: skill-creator only (RECOMMENDED)"
Write-Host ""
Write-Host "To run interactively, download and run directly:"
Write-Host " Invoke-WebRequest -Uri 'https://raw.githubusercontent.com/daymade/claude-code-skills/main/scripts/install.ps1' -OutFile install.ps1"
Write-Host " .\install.ps1"
Write-Host ""
$choice = "1"
}
$commands = @()
$commands += "/plugin marketplace add daymade/claude-code-skills"
@@ -90,7 +104,13 @@ After installation:
Write-Host " 7) repomix-unmixer (repomix extraction)"
Write-Host " 8) llm-icon-finder (AI/LLM icons)"
Write-Host ""
$selections = (Read-Host "Enter skill numbers separated by spaces (e.g., '1 2 3')").Split(' ')
if ($isInteractive) {
$selections = (Read-Host "Enter skill numbers separated by spaces (e.g., '1 2 3')").Split(' ')
} else {
Write-Info "Non-interactive mode: Installing skill-creator only"
$selections = @("1")
}
$skillMap = @{
"1" = "skill-creator"

View File

@@ -34,15 +34,28 @@ fi
echo -e "${GREEN}✓ Claude Code detected${NC}"
echo ""
# Installation options
echo "What would you like to install?"
echo ""
echo "1) skill-creator only (RECOMMENDED - enables you to create your own skills)"
echo "2) All skills"
echo "3) Custom selection"
echo "4) Exit"
echo ""
read -p "Enter your choice (1-4): " choice
# Check if running interactively
if [ -t 0 ]; then
# Interactive mode
echo "What would you like to install?"
echo ""
echo "1) skill-creator only (RECOMMENDED - enables you to create your own skills)"
echo "2) All skills"
echo "3) Custom selection"
echo "4) Exit"
echo ""
read -p "Enter your choice (1-4): " choice
else
# Non-interactive mode (piped from curl)
echo -e "${YELLOW}Running in non-interactive mode.${NC}"
echo "Defaulting to option 1: skill-creator only (RECOMMENDED)"
echo ""
echo "To run interactively, download and run directly:"
echo " curl -fsSL https://raw.githubusercontent.com/daymade/claude-code-skills/main/scripts/install.sh -o install.sh"
echo " bash install.sh"
echo ""
choice=1
fi
case $choice in
1)
@@ -83,7 +96,14 @@ case $choice in
echo " 7) repomix-unmixer (repomix extraction)"
echo " 8) llm-icon-finder (AI/LLM icons)"
echo ""
read -p "Enter skill numbers separated by spaces (e.g., '1 2 3'): " selections
if [ -t 0 ]; then
read -p "Enter skill numbers separated by spaces (e.g., '1 2 3'): " selections
else
echo -e "${YELLOW}Non-interactive mode: Installing skill-creator only${NC}"
selections="1"
fi
echo ""
echo "Run these commands in Claude Code:"
echo ""