From 0f2fa448dcd37646bd93f55e10718d150e9fd637 Mon Sep 17 00:00:00 2001 From: Tw93 Date: Sun, 9 Nov 2025 10:35:28 +0800 Subject: [PATCH] Optimize the installation experience of raycast --- README.md | 4 +-- integrations/README.md | 5 ++-- integrations/setup-raycast.sh | 55 ++++++++++++++++++++++++++--------- 3 files changed, 47 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 68ce520..a094b1e 100644 --- a/README.md +++ b/README.md @@ -70,8 +70,8 @@ Install Raycast integration with one command: curl -fsSL https://raw.githubusercontent.com/tw93/mole/main/integrations/setup-raycast.sh | bash ``` -After installation, open Raycast, search for `Reload Script Directories`, then look for `clean mac`. -If nothing shows up, open `Raycast Settings → Extensions → Script Commands`, click `Add Directories`, and point it to `~/Documents/Raycast/Scripts`. +The installer drops scripts into both `~/Documents/Raycast/Scripts` and `~/Library/Application Support/Raycast/script-commands`, so Raycast should detect at least one automatically. +If you still do not see `clean mac`, open `Raycast Settings → Extensions → Script Commands`, click `Add Directories`, and pick whichever of those two folders you prefer. For Alfred and macOS Shortcuts, see [integrations/README.md](integrations/README.md). diff --git a/integrations/README.md b/integrations/README.md index 0398ac1..1f71ffa 100644 --- a/integrations/README.md +++ b/integrations/README.md @@ -10,9 +10,9 @@ One command install: curl -fsSL https://raw.githubusercontent.com/tw93/Mole/main/integrations/setup-raycast.sh | bash ``` -Then open Raycast and search "Reload Script Directories". +The installer copies scripts into both `~/Documents/Raycast/Scripts` and `~/Library/Application Support/Raycast/script-commands`. After installation, open Raycast and search "Reload Script Directories". -If the commands still do not appear, go to `Raycast Settings → Extensions → Script Commands`, click `Add Directories`, and add `~/Documents/Raycast/Scripts`. +Still nothing? Go to `Raycast Settings → Extensions → Script Commands`, click `Add Directories`, and select either of those folders. Available commands: `clean mac`, `dry run`, `uninstall apps` @@ -42,4 +42,5 @@ Then add to Menu Bar or assign a keyboard shortcut. ```bash rm -rf ~/Documents/Raycast/Scripts/mole-*.sh +rm -rf ~/Library/Application\ Support/Raycast/script-commands/mole-*.sh ``` diff --git a/integrations/setup-raycast.sh b/integrations/setup-raycast.sh index 576f768..0148b3f 100755 --- a/integrations/setup-raycast.sh +++ b/integrations/setup-raycast.sh @@ -4,28 +4,57 @@ set -euo pipefail +BLUE='\033[0;34m' GREEN='\033[0;32m' YELLOW='\033[1;33m' +RED='\033[0;31m' NC='\033[0m' -RAYCAST_DIR="$HOME/Documents/Raycast/Scripts" -BASE_URL="https://raw.githubusercontent.com/tw93/Mole/main/integrations/raycast" +ICON_STEP="➜" +ICON_SUCCESS="✓" +ICON_WARN="!" +ICON_ERR="✗" -# Check Raycast +log_step() { echo -e "${BLUE}${ICON_STEP}${NC} $1"; } +log_success() { echo -e "${GREEN}${ICON_SUCCESS}${NC} $1"; } +log_warn() { echo -e "${YELLOW}${ICON_WARN}${NC} $1"; } +log_error() { echo -e "${RED}${ICON_ERR}${NC} $1"; } + +RAYCAST_DIRS=( + "$HOME/Documents/Raycast/Scripts" + "$HOME/Library/Application Support/Raycast/script-commands" +) +BASE_URL="https://raw.githubusercontent.com/tw93/Mole/main/integrations/raycast" +SCRIPTS=(mole-clean.sh mole-clean-dry-run.sh mole-uninstall.sh) + +echo "" +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" +echo " Mole × Raycast Script Commands" +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + +log_step "Checking Raycast installation..." if [[ ! -d "/Applications/Raycast.app" ]]; then - echo -e "${YELLOW}Raycast not found. Install from: https://raycast.com${NC}" + log_warn "Raycast not found. Install it from https://raycast.com" exit 1 fi -echo "Installing Mole commands for Raycast..." -mkdir -p "$RAYCAST_DIR" - -# Download scripts -for script in mole-clean.sh mole-clean-dry-run.sh mole-uninstall.sh; do - curl -fsSL "$BASE_URL/$script" -o "$RAYCAST_DIR/$script" - chmod +x "$RAYCAST_DIR/$script" +log_step "Syncing scripts (${#SCRIPTS[@]}) to Raycast directories..." +for dir in "${RAYCAST_DIRS[@]}"; do + mkdir -p "$dir" + for script in "${SCRIPTS[@]}"; do + curl -fsSL "$BASE_URL/$script" -o "$dir/$script" + chmod +x "$dir/$script" + done + log_success "Scripts ready in: $dir" done -echo -e "${GREEN}✓${NC} Installed! Open Raycast and search: 'Reload Script Directories'" echo "" -echo "Then search for: 'Clean Mac'" +log_success "All set! Next steps:" +cat <<'INSTRUCTIONS' + 1. Open Raycast and run "Reload Script Directories". + 2. Search for "Clean Mac" / "Dry Run" / "Uninstall Apps". + 3. Missing? Open Raycast Settings → Extensions → Script Commands + and add either folder listed above. +INSTRUCTIONS +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" +echo ""