41 lines
927 B
Bash
Executable File
41 lines
927 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Required parameters:
|
|
# @raycast.schemaVersion 1
|
|
# @raycast.title open-file
|
|
# @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 sel to selection
|
|
if (count of sel) > 0 then
|
|
set thePath to POSIX path of (item 1 of sel as alias)
|
|
return thePath
|
|
else
|
|
set thePath to POSIX path of (target of front window as alias)
|
|
return thePath
|
|
end if
|
|
on error
|
|
return ""
|
|
end try
|
|
end tell
|
|
EOF
|
|
)
|
|
|
|
if [[ -z "$finder_path" ]]; then
|
|
echo "没有检测到访达窗口或选中文件"
|
|
exit 1
|
|
fi
|
|
|
|
open -a "Visual Studio Code" "$finder_path" |