Cheatsheet Pages / tmux Cheatsheet

How to drive tmux from scripts — detached sessions and send-keys

A script should set up a whole workspace — session, windows, commands — ready for you to attach to.

tmux's default prefix is Ctrl-b: “prefix c” means press Ctrl-b, let go, then press c. Every CLI command was run for real against tmux 3.4 in detached test sessions, and every prefix binding was checked against the default binding table.

tmux new-session -d -s job 'make test'          # -d: start detached, run the command inside
tmux send-keys -t job 'ls -la' Enter            # type a command into a pane + press Enter
tmux send-keys -t job:0.0 'echo done' Enter     # targets can be session:window.pane

Good to know

send-keys sends real keystrokes, Enter, C-c and friends included — it is how every tmux automation (and half of all "AI runs my terminal" setups) actually works.

tmux Cheatsheet one-page card — commands that actually work
The full one-page card — tmux Cheatsheet. Get the complete cheatsheet on GitHub