mac自动脚本(f3直接搜或者找其他->自动操作)
然后找到如下功能:
代码如下:
on run {input, parameters}
tell application "Finder"
set currFolder to POSIX path of (folder of the front window as string)
end tell
tell application "Terminal"
do script ("cd " & "'" & currFolder & "'")
end tell
end run
但是,这无法让终端显示在最前方,窗口在后面,需要再次点击程序坞才能聚焦到,那就需要优化一下功能了,新代码如下:
tell application "Finder"
-- 获取当前 Finder 窗口中的文件夹路径
set folderPath to POSIX path of (folder of the front window as alias)
end tell
-- 构建要在 Terminal 中执行的命令
set termina