添加脚本以在 iTerm 中打开 Finder 当前路径

This commit is contained in:
2026-04-15 10:31:27 +08:00
parent b8fbf1e24c
commit ad27c0cc94
2 changed files with 76 additions and 0 deletions

21
sh/close-all-vscode.sh Executable file
View File

@@ -0,0 +1,21 @@
#!/bin/bash
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Close All VSCode
# @raycast.mode compact
# Optional parameters:
# @raycast.icon 🤖
# @raycast.packageName @kevisual/raycast
# Documentation:
# @raycast.description Close all VSCode windows
# @raycast.author abearxiong
# @raycast.authorURL https://raycast.com/abearxiong
osascript <<EOF
tell application "Visual Studio Code"
quit
end tell
EOF

55
sh/open-directory-iterm.sh Executable file
View File

@@ -0,0 +1,55 @@
#!/bin/bash
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Open Directory in iTerm
# @raycast.mode compact
# Optional parameters:
# @raycast.icon 🤖
# @raycast.packageName @kevisual/raycast
# Documentation:
# @raycast.description Open Finder current path in iTerm
# @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
# 用 iTerm 打开文件夹
osascript <<EOF
tell application "iTerm"
activate
try
set newWindow to (create window with default profile)
tell newWindow
tell current session
write text "cd \"$finder_path\""
end tell
end tell
on error
tell current window
create tab with default profile
tell current session
write text "cd \"$finder_path\""
end tell
end tell
end try
end tell
EOF