Skip to content

Add Ghostty split-pane backend via AppleScript (macOS) #35351

@w4sspr

Description

@w4sspr

Feature Request

Add a GhosttyBackend for agent team split panes on macOS, using Ghostty's AppleScript API.

Context

The ITermBackend was recently fixed (v2.1.77) and works great for iTerm2 users. Ghostty is a popular modern terminal on macOS that supports a rich AppleScript object model for programmatic split pane control — everything needed to implement a backend equivalent to ITermBackend.

Ghostty's AppleScript API

Ghostty exposes the following relevant AppleScript capabilities:

tell application "Ghostty"
    -- Create a configuration with working directory and command
    set cfg to new surface configuration
    set initial working directory of cfg to "/path/to/dir"
    set command of cfg to "/bin/zsh"

    -- Split a pane (directions: right, left, down, up)
    set pane2 to split pane1 direction right with configuration cfg

    -- Send text/keys to a specific pane
    input text "echo hello" to pane2
    send key "enter" to pane2

    -- Query pane properties
    get id of pane2
    get working directory of pane2

    -- Close a pane
    close pane2

    -- Other actions
    perform action "equalize_splits" on pane1
end tell

This maps directly to what ITermBackend does with the it2 CLI:

ITermBackend (it2 CLI) GhosttyBackend (AppleScript)
it2 session split -v split terminal direction right with configuration cfg
it2 session split -s <id> split terminal direction down with configuration cfg
Send command via CLI input text "cmd" to terminal + send key "enter"
Parse session ID from output get id of terminal
Kill pane close terminal

Implementation Notes

  • AppleScript calls can be made via osascript -e '...' (similar to how ITermBackend shells out to it2)
  • Ghostty detection: check TERM_PROGRAM=ghostty env var
  • AppleScript is enabled by default in Ghostty (macos-applescript = true)
  • macOS TCC automation permissions may prompt the user on first use
  • teammateMode: "ghostty" and "auto" mode detection would both be needed (like iTerm2)

Environment

  • Platform: macOS
  • Terminal: Ghostty
  • Claude Code: v2.1.77

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