From 98afaabcffe0aabad1d323f5a93664daeba41944 Mon Sep 17 00:00:00 2001 From: Tw93 Date: Tue, 30 Dec 2025 23:05:53 +0800 Subject: [PATCH] fix: make raycast setup safe in non-interactive --- README.md | 2 +- scripts/setup-quick-launchers.sh | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4e224c4..32faaaf 100644 --- a/README.md +++ b/README.md @@ -227,7 +227,7 @@ Launch Mole commands instantly from Raycast or Alfred: curl -fsSL https://raw.githubusercontent.com/tw93/Mole/main/scripts/setup-quick-launchers.sh | bash ``` -Adds 5 commands: `clean`, `uninstall`, `optimize`, `analyze`, `status`. Mole automatically detects your terminal, or you can set `MO_LAUNCHER_APP=` to override. For Raycast, run "Reload Script Directories" to load the new commands. +Adds 5 commands: `clean`, `uninstall`, `optimize`, `analyze`, `status`. Mole automatically detects your terminal, or you can set `MO_LAUNCHER_APP=` to override. For Raycast, if this is your first script directory, add it in Raycast Extensions (Add Script Directory) and then run "Reload Script Directories" to load the new commands. ## Community Love diff --git a/scripts/setup-quick-launchers.sh b/scripts/setup-quick-launchers.sh index 4b84dfa..d10c113 100755 --- a/scripts/setup-quick-launchers.sh +++ b/scripts/setup-quick-launchers.sh @@ -19,6 +19,15 @@ 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"; } log_header() { echo -e "\n${BLUE}==== $1 ====${NC}\n"; } +is_interactive() { [[ -t 1 && -r /dev/tty ]]; } +prompt_enter() { + local prompt="$1" + if is_interactive; then + read -r -p "$prompt" /dev/null 2>&1; then @@ -272,12 +281,16 @@ create_raycast_commands() { echo "" echo "Path copied to your clipboard: $dir" - read -r -p "Press [Enter] once you have added this folder..." + prompt_enter "Press [Enter] once you have added this folder..." done log_header "Finalizing Setup" - read -r -p "In Raycast we need to reload the script directories to sync your new commands. Press [Enter] to reload..." - open "raycast://extensions/raycast/raycast/reload-script-directories" + prompt_enter "In Raycast we need to reload the script directories to sync your new commands. Press [Enter] to reload..." + if open "raycast://extensions/raycast/raycast/reload-script-directories" > /dev/null 2>&1; then + log_step "Raycast script directories reloaded." + else + log_warn "Could not auto-reload Raycast script directories." + fi log_success "Raycast setup complete!" }