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

Optimize the installation experience of raycast

This commit is contained in:
Tw93
2025-11-09 11:03:31 +08:00
parent 5d5c30a602
commit 0ce74f67d9
3 changed files with 29 additions and 9 deletions

View File

@@ -70,7 +70,7 @@ One command sets up Raycast + Alfred shortcuts for `mo clean` and `mo uninstall`
curl -fsSL https://raw.githubusercontent.com/tw93/mole/main/integrations/setup-quick-launchers.sh | bash
```
Done! Raycast gets “Clean Mac / Uninstall Apps”, Alfred gets `mclean / muninstall`.
Done! Raycast gets `clean` / `uninstall`, Alfred gets the same keywords.
Details and manual options live in [integrations/README.md](integrations/README.md).
## Features in Detail

View File

@@ -10,8 +10,8 @@ curl -fsSL https://raw.githubusercontent.com/tw93/Mole/main/integrations/setup-q
This command:
- Adds two Raycast Script Commands (`Clean Mac`, `Uninstall Apps`) to the usual Raycast directories and opens the Script Commands panel so you can reload immediately.
- Creates two Alfred workflows with keywords `mclean` and `muninstall` so you can type and run Mole in Alfred.
- Adds two Raycast Script Commands (`clean`, `uninstall`) to the usual Raycast directories and opens the Script Commands panel so you can reload immediately.
- Creates two Alfred workflows with keywords `clean` and `uninstall` so you can type and run Mole in Alfred.
Both launchers call your locally installed `mo`/`mole` binary directly—no extra prompts or AppleScript permissions needed.
## Alfred

View File

@@ -35,6 +35,9 @@ write_raycast_script() {
local title="$2"
local mo_bin="$3"
local subcommand="$4"
local cmd="${mo_bin} ${subcommand}"
local cmd_escaped="${cmd//\\/\\\\}"
cmd_escaped="${cmd_escaped//\"/\\\"}"
cat > "$target" <<EOF
#!/bin/bash
@@ -51,7 +54,24 @@ set -euo pipefail
echo "🐹 Running ${title}..."
echo ""
"${mo_bin}" ${subcommand}
if [[ -n "\${TERM:-}" && "\${TERM}" != "dumb" ]]; then
"${mo_bin}" ${subcommand}
exit \$?
fi
if command -v osascript >/dev/null 2>&1; then
osascript <<'APPLESCRIPT'
tell application "Terminal"
activate
do script "${cmd_escaped}"
end tell
APPLESCRIPT
else
echo "TERM environment variable not set. Run this manually:"
echo " ${cmd}"
exit 1
fi
EOF
chmod +x "$target"
}
@@ -75,8 +95,8 @@ create_raycast_commands() {
log_step "Installing Raycast commands..."
for dir in "${dirs[@]}"; do
mkdir -p "$dir"
write_raycast_script "$dir/mole-clean.sh" "Clean Mac" "$mo_bin" "clean"
write_raycast_script "$dir/mole-uninstall.sh" "Uninstall Apps" "$mo_bin" "uninstall"
write_raycast_script "$dir/mole-clean.sh" "clean" "$mo_bin" "clean"
write_raycast_script "$dir/mole-uninstall.sh" "uninstall" "$mo_bin" "uninstall"
log_success "Scripts ready in: $dir"
done
@@ -108,8 +128,8 @@ create_alfred_workflow() {
log_step "Installing Alfred workflows..."
local workflows=(
"fun.tw93.mole.clean|Mole Clean|mclean|Run Mole clean|\"${mo_bin}\" clean"
"fun.tw93.mole.uninstall|Mole Uninstall|muninstall|Uninstall apps via Mole|\"${mo_bin}\" uninstall"
"fun.tw93.mole.clean|Mole clean|clean|Run Mole clean|\"${mo_bin}\" clean"
"fun.tw93.mole.uninstall|Mole uninstall|uninstall|Uninstall apps via Mole|\"${mo_bin}\" uninstall"
)
for entry in "${workflows[@]}"; do
@@ -224,7 +244,7 @@ main() {
create_alfred_workflow "$mo_bin"
echo ""
log_success "Done! Raycast (search “Clean Mac”) and Alfred (keywords: mclean / muninstall) are ready."
log_success "Done! Raycast (search “clean” / “uninstall”) and Alfred (keywords: clean / uninstall) are ready."
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
}