Skip to content

[FEATURE] Support terminal notifications when running inside tmux #19976

@rbolkey

Description

@rbolkey

Problem Statement

Claude Code's desktop notifications don't work when running inside tmux. This is because tmux requires applications to wrap OSC sequences in DCS passthrough format, but Claude Code sends plain OSC sequences.

Proposed Solution

Detect when running inside tmux (via $TMUX environment variable) and wrap notification sequences in DCS passthrough format:

# Plain (current):
printf '\033]9;message\007'

# DCS-wrapped for tmux:
printf '\033Ptmux;\033\033]9;message\007\033\\'

This is the standard pattern used by other terminal tools (imgcat, etc.).

Alternative Solutions

Users can create a notification hook as a workaround.

1. Create ~/.claude/hooks/tmux-notify.sh:

#!/bin/bash
# Only wrap for tmux - let Claude Code handle non-tmux natively
[ -z "$TMUX" ] && exit 0

read -r input
message=$(echo "$input" | jq -r '.message // "Claude Code"')
# Must output to /dev/tty - hook stdout is captured by Claude Code
printf '\033Ptmux;\033\033]9;%s\007\033\\' "$message" > /dev/tty

2. Add to ~/.claude/settings.json:

{
  "hooks": {
    "Notification": [
      {
        "hooks": [{ "type": "command", "command": "~/.claude/hooks/tmux-notify.sh" }]
      }
    ]
  }
}

This workaround requires manual setup and isn't discoverable by users.

Additional Context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions