右键下面的文件夹就有打开终端的菜单
收藏
支持打开其他终端吗,比如 Alacritty 之类的三方终端
It's also shell agnostic. Works equally well when your shell is bash or fish or zsh.
它也是无壳的。无论是用 bash、fish 还是 zsh,这种方法都同样有效。
这是仓库的说明
如果是替换了默认终端那估计可以
如果是独立的另一个终端那可能不太行,你试试?
哦好像不对,不清楚,得佬试下
你的终端可以设置为默认终端吗?
[@lin](/user/lin/about) on run {input, parameters}
tell application "Finder"
try
-- 获取当前最前面的 Finder 窗口的路径
set theTarget to (target of front window) as text
set currentPath to POSIX path of theTarget
on error
-- 如果没有打开窗口,默认指向桌面
set currentPath to POSIX path of (desktop as alias)
end try
end tell
-- 启动 Alacritty 并指定工作目录
do shell script "/Applications/Alacritty.app/Contents/MacOS/alacritty --working-directory " & quoted form of currentPath & " > /dev/null 2>&1 &"
end run
弄个 applescript 实现一样的功能,使用方式和这个 cd 一致,
#!/bin/bash
# 获取当前 Finder 窗口路径
finderPath=$(osascript -e 'tell application "Finder" to get the POSIX path of (target of front window as alias)')
# 检查 iTerm 是否正在运行
isRunning=$(osascript -e 'application "iTerm2" is running')
if [ "$isRunning" = "true" ]; then
# iTerm 已在运行,检查是否有窗口
hasWindows=$(osascript -e 'tell application "iTerm2" to count windows')
if [ "$hasWindows" -gt 0 ]; then
# 有窗口,创建新标签页
osascript <<EOF
tell application "iTerm2"
activate
tell current window
create tab with default profile
tell current session of current tab
write text "cd \"$finderPath\""
end tell
end tell
end tell
EOF
else
# 无窗口,创建新窗口
osascript <<EOF
tell application "iTerm2"
activate
set newWindow to (create window with default profile)
tell current session of newWindow
write text "cd \"$finderPath\""
end tell
end tell
EOF
fi
else
# iTerm 未运行,启动并创建新窗口
osascript <<EOF
tell application "iTerm2"
activate
set newWindow to (create window with default profile)
tell current session of newWindow
write text "cd \"$finderPath\""
end tell
end tell
EOF
fi
用的自动操作,这脚本应该可行

感谢分享 👍