Control WezTerm terminal emulator via CLI. Use when managing panes, tabs, workspaces, sending commands to terminals, persistent sessions, or mux-server.
Core Capability: Control WezTerm panes, tabs, and multiplexer domains via CLI.
# List all panes
wezterm cli list
# Split pane horizontally (new pane to right)
wezterm cli split-pane --right
# Split pane vertically (new pane below)
wezterm cli split-pane --bottom
# Send command to specific pane
wezterm cli send-text --pane-id <id> "ls -la\n"
# Create new tab
wezterm cli spawn
| Task | Command |
|---|
| List all panes | wezterm cli list |
| List panes (JSON) | wezterm cli list --format json |
| List GUI windows | wezterm cli list-clients |
| Split right | wezterm cli split-pane --right |
| Split bottom | wezterm cli split-pane --bottom |
| Split with command | wezterm cli split-pane --right -- htop |
| Move focus | wezterm cli activate-pane-direction <up/down/left/right> |
| Activate pane | wezterm cli activate-pane --pane-id <id> |
| Create tab | wezterm cli spawn |
| Create tab with cmd | wezterm cli spawn -- vim |
| Activate tab | wezterm cli activate-tab --tab-index <n> |
| Next/prev tab | wezterm cli activate-tab --tab-relative 1/-1 |
| Send text to pane | wezterm cli send-text --pane-id <id> "text\n" |
| Toggle zoom | wezterm cli zoom-pane --toggle |
| Start new window | wezterm start |
| Start in dir | wezterm start --cwd /path/to/dir |
# Start with htop on right, logs below
wezterm cli split-pane --right -- htop
wezterm cli split-pane --bottom -- tail -f /var/log/syslog
# Send command to specific pane
wezterm cli send-text --pane-id 0 "cd ~/project && npm start\n"
#!/bin/bash
# Create 3-pane layout: main | htop
# logs |
wezterm cli split-pane --right -- htop
wezterm cli activate-pane-direction left
wezterm cli split-pane --bottom -- tail -f app.log
wezterm cli activate-pane-direction up
Config file: ~/.config/wezterm/wezterm.lua
# Show key bindings
wezterm show-keys
# List unique domains
wezterm cli list --format json | jq '.[].domain_name' | sort -u
# Spawn in SSH domain
wezterm cli spawn --domain-name SSH:myserver
# Connect to mux server
wezterm connect unix
The Problem: Mac sleeps, reboots, or loses power → all terminal sessions vanish.
The Solution: wezterm-mux-server on each remote via systemd. Sessions persist on the server.
# Remote server setup (one-time)
mkdir -p ~/.config/systemd/user
cat > ~/.config/systemd/user/wezterm-mux-server.service << 'EOF'
[Unit]
Description=WezTerm Mux Server
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/wezterm-mux-server --daemonize=false
Restart=on-failure
RestartSec=5
[Install]
WantedBy=default.target
EOF
systemctl --user daemon-reload
systemctl --user enable --now wezterm-mux-server
sudo loginctl enable-linger $USER
-- Local config: SSH domain with mux
config.ssh_domains = {
{
name = 'dev-server',
remote_address = '10.20.30.1',
username = 'ubuntu',
multiplexing = 'WezTerm', -- Key setting
},
}
See PERSISTENT-SESSIONS.md for full setup with domain colors and smart startup.
macOS:
/Applications/WezTerm.app/Contents/MacOS/wezterm
Or add to PATH for easier access.
| Topic | Reference |
|---|---|
| Full command reference | COMMANDS.md |
| Persistent remote sessions | PERSISTENT-SESSIONS.md |