raycast/sh/open-directory.sh
2025-08-16 00:41:07 +08:00

36 lines
739 B
Bash
Executable File

#!/bin/bash
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title open-directory
# @raycast.mode compact
# Optional parameters:
# @raycast.icon 🤖
# @raycast.packageName @kevisual/raycast
# Documentation:
# @raycast.description open
# @raycast.author abearxiong
# @raycast.authorURL https://raycast.com/abearxiong
# 获取访达当前窗口路径
finder_path=$(osascript <<EOF
tell application "Finder"
try
set thePath to POSIX path of (target of front window as alias)
return thePath
on error
return ""
end try
end tell
EOF
)
if [[ -z "$finder_path" ]]; then
echo "没有检测到访达窗口"
exit 1
fi
# 用 VS Code 打开文件夹
open -a "Visual Studio Code" "$finder_path"