You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Finder服务故障:默认及自定义“在文件夹新建终端”功能无法运行

解决Sierra系统中Finder终端服务失效的问题

先别急,这种毫无预兆突然失效的情况,大多是系统服务缓存、脚本语法或者权限紊乱导致的,我给你几个针对性的解决步骤:

1. 先修复脚本里的致命语法错误

你提供的脚本里藏了个容易忽略的问题:do script "cd " & theWin里的&是HTML转义字符,AppleScript根本识别不了,这会直接导致脚本执行失败,服务自然无法工作。把它改成正常的&就好:

on run {input, parameters}
    tell application "Finder"
        set myWin to window 1
        set theWin to (quoted form of POSIX path of (target of myWin as alias))
        tell application "Terminal"
            activate
            tell window 1
                do script "cd " & theWin
            end tell
        end tell
    end tell
    return input
end run

2. 重置Services服务缓存

系统服务的缓存偶尔会出现紊乱,这是无预警失效的常见原因:

  • 先关闭所有Finder窗口
  • 打开终端,执行命令刷新服务缓存:
    /System/Library/CoreServices/pbs -flush
    
  • 接着重启Finder让缓存生效:
    killall Finder
    
  • 也可以手动去「系统偏好设置 → 键盘 → 快捷键 → 服务」,先取消勾选你的自定义服务,重启Mac后再重新勾选。

3. 检查自定义服务的Automator配置

打开Automator找到你的自定义服务,确认以下核心配置:

  • 顶部的「服务收到选定的」选项选择「文件夹」
  • 「位于」选项选择「Finder.app」
    只有这样才能确保服务只在Finder中针对文件夹触发,不会出现在错误的菜单场景里。

4. 重置用户权限(终极排查)

如果以上方法都无效,可能是系统权限紊乱导致服务无法正常加载:

  • 打开终端,执行权限重置命令:
    diskutil resetUserPermissions / $(id -u)
    
  • 执行完成后重启Mac,再测试服务是否恢复正常。

5. 替换为更稳定的脚本版本

你原来的脚本依赖Finder的当前窗口,如果Finder没有打开窗口就会失效,换成下面这个脚本,直接接收选定的文件夹作为输入,兼容性和稳定性更好:

on run {input, parameters}
    set targetPath to quoted form of POSIX path of (item 1 of input as alias)
    tell application "Terminal"
        activate
        if exists window 1 then
            do script "cd " & targetPath in window 1
        else
            do script "cd " & targetPath
        end if
    end tell
    return input
end run

按照这些步骤一步步排查,应该能解决你的问题。

内容的提问来源于stack exchange,提问作者Karric

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 03:21:29