AgentSkillsCN

tmux

全面管理 tmux 终端复用器:会话、窗口、窗格、布局、脚本编写以及配置。 自动激活于:“tmux”、“session”、“window”、“pane”、“split”、“attach”、“detach”、“复用器”。

SKILL.md
--- frontmatter
name: tmux
description: |
  Complete tmux terminal multiplexer management: sessions, windows, panes, layouts, scripting, and configuration.
  Auto-activates on: "tmux", "session", "window", "pane", "split", "attach", "detach", "multiplexer".
license: MIT
compatibility: Requires tmux (3.0+). Works on Linux/macOS/WSL.
metadata:
  version: "1.0"
allowed-tools: Bash Read Edit Write Glob Grep

tmux

Complete tmux management for terminal multiplexing.

Core Concepts

code
┌─────────────────────────────────────────────────────────────┐
│ SERVER (one per socket)                                     │
│  ┌───────────────────────────────────────────────────────┐  │
│  │ SESSION ($0, $1, ...)                                 │  │
│  │  ┌─────────────────┐  ┌─────────────────┐            │  │
│  │  │ WINDOW (@0)     │  │ WINDOW (@1)     │  ...       │  │
│  │  │  ┌────┬────┐   │  │  ┌────────────┐ │            │  │
│  │  │  │PANE│PANE│   │  │  │   PANE     │ │            │  │
│  │  │  │ %0 │ %1 │   │  │  │    %2      │ │            │  │
│  │  │  └────┴────┘   │  │  └────────────┘ │            │  │
│  │  └─────────────────┘  └─────────────────┘            │  │
│  └───────────────────────────────────────────────────────┘  │
└─────────────────────────────────────────────────────────────┘
  • Server: Background process managing all state
  • Session ($id): Named container of windows, persists after detach
  • Window (@id): Tab-like container of panes within a session
  • Pane (%id): Individual terminal within a window
  • Client: Terminal attached to a session

Router

User saysLoad referenceDo
list sessions / statusreferences/session-management.mdinspect sessions
new session / create sessionreferences/session-management.mdcreate session
attach / detachreferences/session-management.mdattach/detach
kill sessionreferences/session-management.mdterminate session
new window / create windowreferences/window-management.mdcreate window
rename windowreferences/window-management.mdrename window
kill window / close windowreferences/window-management.mdclose window
switch windowreferences/window-management.mdnavigate windows
split / new panereferences/pane-management.mdsplit pane
resize panereferences/pane-management.mdresize pane
move pane / swap panereferences/pane-management.mdrearrange panes
kill pane / close panereferences/pane-management.mdclose pane
layoutreferences/layouts.mdapply/manage layouts
copy / paste / bufferreferences/copy-mode.mdcopy mode operations
config / tmux.conf / settingsreferences/configuration.mdconfigure tmux
keybind / bind / unbindreferences/keybindings.mdkey bindings
script / automate / send-keysreferences/scripting.mdscripting/automation
capture / log / outputreferences/scripting.mdcapture pane content
help / keys / cheatsheetinlineshow key reference

Default Key Bindings (Prefix: C-b)

Session

KeyAction
dDetach from session
sList/switch sessions
$Rename session
( / )Previous/next session

Window

KeyAction
cCreate window
&Kill window (confirm)
,Rename window
0-9Switch to window N
n / pNext/previous window
lLast window
wList windows
fFind window

Pane

KeyAction
%Split horizontally (left/right)
"Split vertically (top/bottom)
xKill pane (confirm)
oCycle panes
qShow pane numbers
zToggle zoom
{ / }Swap pane left/right
!Break pane to window
ArrowsNavigate panes
SpaceCycle layouts
C-oRotate panes

Copy Mode

KeyAction
[Enter copy mode
]Paste buffer
=Choose paste buffer
#List buffers

Quick Reference

bash
# Session
tmux new -s name              # Create named session
tmux attach -t name           # Attach to session
tmux ls                       # List sessions
tmux kill-session -t name     # Kill session

# Window
tmux new-window -n name       # Create named window
tmux select-window -t :N      # Go to window N
tmux rename-window name       # Rename current window

# Pane
tmux split-window -h          # Split horizontal
tmux split-window -v          # Split vertical
tmux select-pane -t :.N       # Go to pane N
tmux resize-pane -D 5         # Resize down 5 lines

# Info
tmux list-keys                # All key bindings
tmux info                     # Server info

Safety Rules

  • Confirm before kill: Always confirm before kill-session, kill-window, kill-pane
  • Check attachments: Before killing, check if session has active clients
  • Preserve work: Warn if panes have running processes
  • Config backup: Before editing ~/.tmux.conf, suggest backup

Confirmation Policy

Read-only (always OK):

  • tmux ls, list-sessions, list-windows, list-panes
  • tmux info, show-options, display-message
  • tmux list-keys, list-buffers

Requires confirmation:

  • kill-session, kill-window, kill-pane
  • kill-server
  • Editing ~/.tmux.conf
  • send-keys to panes (can affect running processes)

Environment Variables

VariableDescription
TMUXSocket path (set inside tmux)
TMUX_PANECurrent pane ID

Check if inside tmux: [ -n "$TMUX" ]

Troubleshooting

IssueSolution
"no server running"Start with tmux or tmux new
"sessions should be nested"Unset $TMUX or use tmux -u
Detached session lostCheck tmux ls, attach with tmux attach
Colors not workingSet TERM=xterm-256color or set -g default-terminal "tmux-256color"
Mouse not workingset -g mouse on in config