小mac

vim ~/.claude/settings.json

{
  "permissions": {
    "allow": [
      "Bash(ls:*)"
    ]
  },
  "model": "Claude Opus 4.7",
  "hooks": {
    "Notification": [
      {
        "matcher": "",
        "hooks": [
          {
            "type": "command",
            "command": "osascript -e 'display dialog \"牛马需要你!\" with title \"老板\" buttons {\"这就来\"} default button 1'"
          }
        ]
      }
    ]
  }
}

大mac

{
  "model": "opus[1m]",
  "hooks": {
    "Notification": [
      {
        "matcher": "permission_prompt",
        "hooks": [
          {
            "type": "command",
            "command": "/Users/mac/.claude/hooks/force-approval-popup.sh"
          }
        ]
      }
    ]
  }
}
#!/usr/bin/env bash
set -euo pipefail

json="$(cat)"

message="$(printf '%s' "$json" | python3 -c 'import sys,json; d=json.load(sys.stdin); print(d.get("message","Claude Code needs your approval"))')"
title="$(printf '%s' "$json" | python3 -c 'import sys,json; d=json.load(sys.stdin); print(d.get("title","Claude Code"))')"

osascript -e "display notification \"$message\" with title \"$title\" subtitle \"Approval required\""
afplay /System/Library/Sounds/Glass.aiff

osascript <<EOF
tell application "System Events"
    activate
    display dialog "$message" with title "$title" buttons {"OK"} default button "OK"
end tell
EOF
~                                                                               
~                                                                               
"~/.claude/hooks/force-approval-popup.sh

当前小mac能用的

settings.josn

{
  "model": "opus[1m]",
  "hooks": {
    "Notification": [
      {
        "matcher": "permission_prompt",
        "hooks": [
          {
            "type": "command",
            "command": "/Users/zeng/.claude/hooks/force-approval-popup.sh"
          }
        ]
      }
    ]
  },
  "theme": "light"
}

/Users/zeng/.claude/hooks/force-approval-popup.sh

#!/usr/bin/env bash
set -euo pipefail

json="$(cat)"

message="$(printf '%s' "$json" | python3 -c 'import sys,json; d=json.load(sys.stdin); print(d.get("message","Claude Code needs your approval"))')"
title="$(printf '%s' "$json" | python3 -c 'import sys,json; d=json.load(sys.stdin); print(d.get("title","Claude Code"))')"

osascript -e "display notification \"$message\" with title \"$title\" subtitle \"Approval required\""
afplay /System/Library/Sounds/Funk.aiff

osascript <<EOF
tell application "System Events"
    activate
    display dialog "$message" with title "$title" buttons {"OK"} default button "OK"
end tell
EOF

Logo

欢迎加入DeepSeek 技术社区。在这里,你可以找到志同道合的朋友,共同探索AI技术的奥秘。

更多推荐