Introduction to Control Mode
tmux’s control mode provides a textual interface for programmatic interaction with tmux. It allows applications to communicate with tmux using a simple, text-based protocol instead of terminal escape sequences.Control mode is designed for applications that need to programmatically control tmux, such as terminal multiplexer frontends, testing tools, or automation scripts.
Starting Control Mode
Basic Invocation
Start tmux in control mode with the-C flag:
Disable Echo
Use-CC to disable echo:
Protocol Overview
In control mode, communication happens through:- Input: Commands sent to tmux on stdin, one per line
- Output: Responses and notifications on stdout
Command Structure
Send tmux commands as text:Response Format
Each command produces a response block:Example Session
Notifications
Control mode sends notifications for events. Notifications never occur inside output blocks.Common Notifications
- Session Events
- Window Events
- Pane Events
- Client Events
Buffer and Subscription Events
Client Control
Setting Client Size
Control the size of windows/panes visible to the control mode client:Client Flags
Control mode clients can have special flags:active-pane- Client has independent active paneignore-size- Client doesn’t affect window sizeno-detach-on-destroy- Don’t detach when session destroyedno-output- Client doesn’t receive pane outputpause-after=seconds- Pause output when behindread-only- Client is read-onlywait-exit- Wait for empty line before exiting
Output Control
Pane Output Actions
Control pane output flow:The pause-after Flag
Automatically pause panes when output is behind:Subscriptions
Subscribe to format changes to receive notifications:Subscription Types
The subscriptionwhat field can be:
- Empty - Check attached session
%0,%1- Specific pane ID%*- All panes in attached session@0,@1- Specific window ID@*- All windows in attached session
Subscription Notifications
When subscribed format changes:Reading Pane Content
Output Notification
By default, pane output is sent via%output notifications:
\nnn).
Extended Output
Withpause-after flag, output uses extended format: