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 terminalCommand to "cd '" & quoted form of folderPath & "'; pwd"
-- 告诉 Terminal 应用执行命令
tell application "Terminal"
-- 尝试激活 Terminal 应用(但这不保证窗口会出现在最前面)
activate
end tell
保存,命名好你想要取得名字,然后进入“系统偏好设置” > “键盘” > “快捷键” > “服务”中,找到"通用",里面有你命名好的文件名,双击设置快捷键并打勾即可。
嗯,这下可以了,免去了花钱买某些软件还经常报错失败的问题。
注意:
需要确定好该快捷键是没有被占用的,如果使用后不起作用说明被占用了,换一个快捷键并设置即可。