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

fix(raycast): defer command interpolation

This commit is contained in:
tw93
2026-02-04 16:39:02 +08:00
parent 41a26204fb
commit 8bf3d419f5

View File

@@ -59,12 +59,18 @@ write_raycast_script() {
# Optional parameters: # Optional parameters:
# @raycast.icon 🐹 # @raycast.icon 🐹
# ──────────────────────────────────────────────────────────
# Script execution begins below
# ──────────────────────────────────────────────────────────
set -euo pipefail set -euo pipefail
echo "🐹 Running ${title}..." echo "🐹 Running ${title}..."
echo "" echo ""
CMD="${raw_cmd}"
CMD_ESCAPED="${cmd_escaped}" # Command to execute
_MO_RAW_CMD="${raw_cmd}"
_MO_CMD_ESCAPED="${cmd_escaped}"
has_app() { has_app() {
local name="\$1" local name="\$1"
@@ -114,7 +120,7 @@ launch_with_app() {
Terminal) Terminal)
if command -v osascript >/dev/null 2>&1; then if command -v osascript >/dev/null 2>&1; then
osascript <<'APPLESCRIPT' osascript <<'APPLESCRIPT'
set targetCommand to "${cmd_escaped}" set targetCommand to "\${_MO_CMD_ESCAPED}"
tell application "Terminal" tell application "Terminal"
activate activate
do script targetCommand do script targetCommand
@@ -126,7 +132,7 @@ APPLESCRIPT
iTerm|iTerm2) iTerm|iTerm2)
if command -v osascript >/dev/null 2>&1; then if command -v osascript >/dev/null 2>&1; then
osascript <<'APPLESCRIPT' osascript <<'APPLESCRIPT'
set targetCommand to "${cmd_escaped}" set targetCommand to "\${_MO_CMD_ESCAPED}"
tell application "iTerm2" tell application "iTerm2"
activate activate
try try
@@ -150,52 +156,52 @@ APPLESCRIPT
;; ;;
Alacritty) Alacritty)
if launcher_available "Alacritty" && command -v open >/dev/null 2>&1; then if launcher_available "Alacritty" && command -v open >/dev/null 2>&1; then
open -na "Alacritty" --args -e /bin/zsh -lc "${raw_cmd}" open -na "Alacritty" --args -e /bin/zsh -lc "\${_MO_RAW_CMD}"
return \$? return \$?
fi fi
;; ;;
Kitty) Kitty)
if has_bin "kitty"; then if has_bin "kitty"; then
kitty --hold /bin/zsh -lc "${raw_cmd}" kitty --hold /bin/zsh -lc "\${_MO_RAW_CMD}"
return \$? return \$?
elif [[ -x "/Applications/kitty.app/Contents/MacOS/kitty" ]]; then elif [[ -x "/Applications/kitty.app/Contents/MacOS/kitty" ]]; then
"/Applications/kitty.app/Contents/MacOS/kitty" --hold /bin/zsh -lc "${raw_cmd}" "/Applications/kitty.app/Contents/MacOS/kitty" --hold /bin/zsh -lc "\${_MO_RAW_CMD}"
return \$? return \$?
fi fi
;; ;;
WezTerm) WezTerm)
if has_bin "wezterm"; then if has_bin "wezterm"; then
wezterm start -- /bin/zsh -lc "${raw_cmd}" wezterm start -- /bin/zsh -lc "\${_MO_RAW_CMD}"
return \$? return \$?
elif [[ -x "/Applications/WezTerm.app/Contents/MacOS/wezterm" ]]; then elif [[ -x "/Applications/WezTerm.app/Contents/MacOS/wezterm" ]]; then
"/Applications/WezTerm.app/Contents/MacOS/wezterm" start -- /bin/zsh -lc "${raw_cmd}" "/Applications/WezTerm.app/Contents/MacOS/wezterm" start -- /bin/zsh -lc "\${_MO_RAW_CMD}"
return \$? return \$?
fi fi
;; ;;
Ghostty) Ghostty)
if has_bin "ghostty"; then if has_bin "ghostty"; then
ghostty --command "/bin/zsh" -- -lc "${raw_cmd}" ghostty --command "/bin/zsh" -- -lc "\${_MO_RAW_CMD}"
return \$? return \$?
elif [[ -x "/Applications/Ghostty.app/Contents/MacOS/ghostty" ]]; then elif [[ -x "/Applications/Ghostty.app/Contents/MacOS/ghostty" ]]; then
"/Applications/Ghostty.app/Contents/MacOS/ghostty" --command "/bin/zsh" -- -lc "${raw_cmd}" "/Applications/Ghostty.app/Contents/MacOS/ghostty" --command "/bin/zsh" -- -lc "\${_MO_RAW_CMD}"
return \$? return \$?
fi fi
;; ;;
Hyper) Hyper)
if launcher_available "Hyper" && command -v open >/dev/null 2>&1; then if launcher_available "Hyper" && command -v open >/dev/null 2>&1; then
open -na "Hyper" --args /bin/zsh -lc "${raw_cmd}" open -na "Hyper" --args /bin/zsh -lc "\${_MO_RAW_CMD}"
return \$? return \$?
fi fi
;; ;;
WindTerm) WindTerm)
if launcher_available "WindTerm" && command -v open >/dev/null 2>&1; then if launcher_available "WindTerm" && command -v open >/dev/null 2>&1; then
open -na "WindTerm" --args /bin/zsh -lc "${raw_cmd}" open -na "WindTerm" --args /bin/zsh -lc "\${_MO_RAW_CMD}"
return \$? return \$?
fi fi
;; ;;
Warp) Warp)
if launcher_available "Warp" && command -v open >/dev/null 2>&1; then if launcher_available "Warp" && command -v open >/dev/null 2>&1; then
open -na "Warp" --args /bin/zsh -lc "${raw_cmd}" open -na "Warp" --args /bin/zsh -lc "\${_MO_RAW_CMD}"
return \$? return \$?
fi fi
;; ;;
@@ -223,7 +229,7 @@ fi
echo "TERM environment variable not set and no launcher succeeded." echo "TERM environment variable not set and no launcher succeeded."
echo "Run this manually:" echo "Run this manually:"
echo " ${raw_cmd}" echo " \${_MO_RAW_CMD}"
exit 1 exit 1
EOF EOF
chmod +x "$target" chmod +x "$target"