1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-04 15:04:42 +00:00

Optimize the installation experience of raycast

This commit is contained in:
Tw93
2025-11-09 10:41:30 +08:00
parent 0f2fa448dc
commit 0db4d565cb
4 changed files with 131 additions and 28 deletions

View File

@@ -64,16 +64,14 @@ mo --version # Show installed version
## Quick Launchers ## Quick Launchers
Install Raycast integration with one command: Generate Spotlight / Shortcuts launchers with one command:
```bash ```bash
curl -fsSL https://raw.githubusercontent.com/tw93/mole/main/integrations/setup-raycast.sh | bash curl -fsSL https://raw.githubusercontent.com/tw93/mole/main/integrations/setup-shortcut-apps.sh | bash
``` ```
The installer drops scripts into both `~/Documents/Raycast/Scripts` and `~/Library/Application Support/Raycast/script-commands`, so Raycast should detect at least one automatically. This drops tiny apps such as “Mole Clean” into `~/Applications` so you can trigger them from Spotlight, Dock, or the Shortcuts app.
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, Shortcuts details, and more, see [integrations/README.md](integrations/README.md).
For Alfred and macOS Shortcuts, see [integrations/README.md](integrations/README.md).
## Features in Detail ## Features in Detail

View File

@@ -2,19 +2,22 @@
Quick launcher integrations for Mole. Quick launcher integrations for Mole.
## Raycast ## Shortcut Apps (Spotlight & Shortcuts)
One command install: Generate ready-to-use launcher apps (Clean / Dry Run / Uninstall):
```bash ```bash
curl -fsSL https://raw.githubusercontent.com/tw93/Mole/main/integrations/setup-raycast.sh | bash curl -fsSL https://raw.githubusercontent.com/tw93/Mole/main/integrations/setup-shortcut-apps.sh | bash
``` ```
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". This drops them into `~/Applications`, so you can trigger Mole via Spotlight, Dock, or Shortcuts (“Open App” action).
Prefer to craft your own shortcut? Add “Run Shell Script”:
Still nothing? Go to `Raycast Settings → Extensions → Script Commands`, click `Add Directories`, and select either of those folders. ```bash
mo clean
```
Available commands: `clean mac`, `dry run`, `uninstall apps` Dry run: `mo clean --dry-run` • Uninstall: `mo uninstall`
## Alfred ## Alfred
@@ -28,19 +31,12 @@ For dry-run: `mo clean --dry-run`
For uninstall: `mo uninstall` For uninstall: `mo uninstall`
## macOS Shortcuts
Create a shortcut with "Run Shell Script":
```bash
mo clean
```
Then add to Menu Bar or assign a keyboard shortcut.
## Uninstall ## Uninstall
```bash ```bash
rm -rf ~/Applications/Mole\ Clean*.app
rm -rf ~/Applications/Mole\ Uninstall\ Apps.app
# Legacy Raycast script commands (if you installed them before switching)
rm -rf ~/Documents/Raycast/Scripts/mole-*.sh rm -rf ~/Documents/Raycast/Scripts/mole-*.sh
rm -rf ~/Library/Application\ Support/Raycast/script-commands/mole-*.sh rm -rf ~/Library/Application\ Support/Raycast/script-commands/mole-*.sh
``` ```

View File

@@ -20,10 +20,20 @@ log_success() { echo -e "${GREEN}${ICON_SUCCESS}${NC} $1"; }
log_warn() { echo -e "${YELLOW}${ICON_WARN}${NC} $1"; } log_warn() { echo -e "${YELLOW}${ICON_WARN}${NC} $1"; }
log_error() { echo -e "${RED}${ICON_ERR}${NC} $1"; } log_error() { echo -e "${RED}${ICON_ERR}${NC} $1"; }
RAYCAST_DIRS=( DEFAULT_DIR="$HOME/Library/Application Support/Raycast/script-commands"
"$HOME/Documents/Raycast/Scripts" ALT_DIR="$HOME/Documents/Raycast/Scripts"
"$HOME/Library/Application Support/Raycast/script-commands" RAYCAST_DIRS=()
)
if [[ -d "$DEFAULT_DIR" ]]; then
RAYCAST_DIRS+=("$DEFAULT_DIR")
fi
if [[ -d "$ALT_DIR" ]]; then
RAYCAST_DIRS+=("$ALT_DIR")
fi
if [[ ${#RAYCAST_DIRS[@]} -eq 0 ]]; then
RAYCAST_DIRS+=("$DEFAULT_DIR")
fi
BASE_URL="https://raw.githubusercontent.com/tw93/Mole/main/integrations/raycast" BASE_URL="https://raw.githubusercontent.com/tw93/Mole/main/integrations/raycast"
SCRIPTS=(mole-clean.sh mole-clean-dry-run.sh mole-uninstall.sh) SCRIPTS=(mole-clean.sh mole-clean-dry-run.sh mole-uninstall.sh)
@@ -50,11 +60,17 @@ done
echo "" echo ""
log_success "All set! Next steps:" log_success "All set! Next steps:"
cat <<'INSTRUCTIONS' cat <<INSTRUCTIONS
1. Open Raycast and run "Reload Script Directories". 1. Open Raycast and run "Reload Script Directories".
2. Search for "Clean Mac" / "Dry Run" / "Uninstall Apps". 2. Search for "Clean Mac" / "Dry Run" / "Uninstall Apps".
3. Missing? Open Raycast Settings → Extensions → Script Commands 3. Missing? Open Raycast Settings → Extensions → Script Commands
and add either folder listed above. and add $(printf '"%s" ' "${RAYCAST_DIRS[@]}").
INSTRUCTIONS INSTRUCTIONS
if open "raycast://extensions/script-commands" > /dev/null 2>&1; then
log_step "Raycast settings opened so you can confirm the directory."
else
log_warn "Could not auto-open Raycast. Launch it manually if needed."
fi
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "" echo ""

View File

@@ -0,0 +1,93 @@
#!/bin/bash
# Create double-clickable Mole launchers (works great with Spotlight & Shortcuts).
set -euo pipefail
BLUE='\033[0;34m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m'
ICON_STEP="➜"
ICON_SUCCESS="✓"
ICON_WARN="!"
ICON_ERR="✗"
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"; }
if ! command -v osascript >/dev/null 2>&1 || ! command -v osacompile >/dev/null 2>&1; then
log_error "This installer needs AppleScript tools (osascript / osacompile). They ship with macOS."
exit 1
fi
# Resolve Mole executable
if command -v mo >/dev/null 2>&1; then
MO_BIN="$(command -v mo)"
elif command -v mole >/dev/null 2>&1; then
MO_BIN="$(command -v mole)"
else
log_error "Couldn't find Mole. Install via Homebrew or the install.sh script first."
exit 1
fi
APP_DIR_BASE="${APP_DIR_BASE:-$HOME/Applications}"
mkdir -p "$APP_DIR_BASE"
declare -a ACTIONS=(
"Mole Clean|$MO_BIN clean|Run full clean with Mole"
"Mole Clean (Dry Run)|$MO_BIN clean --dry-run|Preview cleanup targets"
"Mole Uninstall Apps|$MO_BIN uninstall|Interactive app uninstaller"
)
create_launcher() {
local name="$1"
local command="$2"
local description="$3"
local app_path="$APP_DIR_BASE/$name.app"
local tmp_scpt
tmp_scpt="$(mktemp)"
# Escape backslashes and quotes for AppleScript literal
local escaped_cmd="${command//\\/\\\\}"
escaped_cmd="${escaped_cmd//\"/\\\"}"
cat > "$tmp_scpt" <<EOF
on run
set targetCommand to "${escaped_cmd}"
tell application "Terminal"
activate
do script targetCommand
end tell
end run
EOF
osacompile -o "$app_path" "$tmp_scpt"
rm -f "$tmp_scpt"
/usr/bin/plutil -replace CFBundleIdentifier -string "fun.tw93.mole.$(echo "$name" | tr '[:upper:]' '[:lower:]' | tr -cd '[:alnum:]' )" "$app_path/Contents/Info.plist" 2>/dev/null || true
/usr/bin/plutil -replace CFBundleDisplayName -string "$name" "$app_path/Contents/Info.plist" 2>/dev/null || true
log_success "Created ${name}${app_path}"
log_step "You can now launch it from Spotlight or add to macOS Shortcuts."
echo " ${description}"
}
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " Mole macOS Launcher Creator"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
log_step "Installing launchers into: $APP_DIR_BASE"
for entry in "${ACTIONS[@]}"; do
IFS="|" read -r name cmd desc <<< "$entry"
create_launcher "$name" "$cmd" "$desc"
done
echo ""
log_step "Tip: open Shortcuts.app → New Shortcut → Add Action → 'Open App', then pick the launcher."
log_success "Done! Search Spotlight for “Mole Clean” to try it."
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""