Multi-Attach¶
sbsh supports multiple clients attaching to the same terminal concurrently. This enables collaborative debugging, pair programming, and shared terminal sessions.
How Multi-Attach Works¶
Multiple clients can connect to the same terminal simultaneously:
Terminal (my-terminal)
├── Client 1 (user@host1)
├── Client 2 (user@host2)
└── Client 3 (user@host3)
All clients see the same terminal output and can send input. Input from any client is forwarded to the terminal.
Use Cases¶
Pair Programming¶
Two developers can attach to the same terminal:
# Developer 1
sb attach debug-session
# Developer 2 (from different machine)
sb attach debug-session
Both see the same output and can collaborate in real-time.
Collaborative Debugging¶
Multiple team members can attach to a shared debugging terminal:
# Team member 1
sb attach production-debug
# Team member 2
sb attach production-debug
# Team member 3
sb attach production-debug
Shared Infrastructure Terminals¶
Team members can access shared maintenance terminals:
# SRE attaches to shared terminal
sb attach k8s-maintenance
# Developer attaches to same terminal
sb attach k8s-maintenance
Multi-Attach Behavior¶
Input Handling¶
Input from any attached client is forwarded to the terminal. If multiple clients send input simultaneously, it's interleaved.
Output Broadcasting¶
Terminal output is broadcast to all attached clients. Each client receives a copy of all output.
Detachment¶
When a client detaches, other clients remain attached. The terminal continues running independently.
Discovery Across Machines¶
Multi-attach works across machines when they share access to the ~/.sbsh directory:
# Machine 1
sbsh -p my-profile --name shared-terminal
# Machine 2 (with shared ~/.sbsh)
sb attach shared-terminal
Limitations¶
- Input from multiple clients is interleaved (no coordination)
- All clients see the same output (no filtering)
- Requires shared filesystem access for cross-machine multi-attach
Related Concepts¶
- Terminals - Terminal lifecycle
- Client - Client architecture
- Terminal State - State management