AppleScript
Address Moth windows, tabs, and panes from macOS scripts.
Open the scripting dictionary
In Script Editor, choose File → Open Dictionary…, then select Moth. Windows contain tabs, and tabs contain panes. Tabs and panes expose stable text IDs, names, read-only contents including scrollback, and a busy property.
busy becomes false when shell integration reports an input prompt. Without shell integration it remains true; it does not indicate whether an arbitrary remote program is ready.
Run a command in a new window
tell application "Moth"
activate
set sessionTab to do script "pwd"
return id of sessionTab
end tell
do script returns the target tab. Omitting the command text opens an empty terminal window.
Target an existing pane
tell application "Moth"
do script "git status --short" in selected tab of front window
return contents of selected pane of selected tab of front window
end tell
Use a window, tab, or pane after in. A window addresses its selected tab, and a tab addresses its selected pane. Input goes only to that pane, even when keyboard broadcasting is enabled. Moth sends Enter after the command and uses the pane’s configured text encoding. Returning from do script means input was sent; the command can still be running.
Use pane id "PANE_UUID" of tab id "TAB_UUID" of window 1 to address a session after reordering tabs or panes. Closed, exited, or unavailable sessions report an AppleScript error.
Window properties and selection
Windows expose name, id, index, bounds, and visible. You can set a window’s selected tab to another tab belonging to that window. Closing a window or quitting uses Moth’s normal confirmation behaviour.
For shell scripts that list panes, send control keys, resize splits, or manage detached sessions, use the command-line interface.